I am trying to replace on the line Application.Run "c:\\users\\navin\\test\\"
with path
but it won't work. (Error 1004).
Sub test()
Dim path As String
path = "c:\users\navin\test\"
Workbooks.Open (path & "excel.xlsb")
Application.Run "'c:\users\navin\test\new.xlsb!macro1'"
Workbooks("excel.xlsb").Close SaveChanges:=True
End Sub
Currently you open a workbook called excel.xlsb
and then attempt to run a macro in a workbook called new.xslb
. You also have two sets of quotes, which is likely to cause problems.
Where you attempt to run the macro, you should reference only the name of the workbook.
Application.Run "excel.xlsb!macro1"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.