the purpose is to call a function (name is repeat) from another workbook wth path('D:\EXcel VBA\practice\trial.xls'). I find the following is successful.
Private Sub CommandButton1_Click()
Workbooks.Open("D:\EXcel VBA\practice\trial.xls")
Application.Run "'D:\EXcel VBA\practice\trial.xls'!repeat"
End Sub
However, When I try to use a string "file" to replace the long name 'D:\EXcel VBA\practice\trial.xls' It fails as shown below. error is with the last statement Application.Run 'file!repeat'
Help needed. thanks!!!
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim file, As String
file = "D:\EXcel VBA\practice\trial.xls"
Workbooks.Open file
Application.Run 'file!repeat'
End Sub
Private Sub CommandButton1_Click()
Workbooks.Open("D:\EXcel VBA\practice\trial.xls")
Application.Run "'D:\EXcel VBA\practice\trial.xls'!repeat"
End Sub
However, When I try to use a string "file" to replace the long name 'D:\EXcel VBA\practice\trial.xls' It fails as shown below. error is with the last statement Application.Run 'file!repeat'
Help needed. thanks!!!
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim file, As String
file = "D:\EXcel VBA\practice\trial.xls"
Workbooks.Open file
Application.Run 'file!repeat'
End Sub