Hi I have the following code. I'm trying to open a workbook (e.g. WorkWithExFile2) from current active workbook (e.g. WorkWithExFile) and run a procedure/macro that I have in active workbook (WorkWithExFile) on the workbook that I brought up (WorkWithExFile2) which was then saved as (test.xlsm)
I'm not sure this is the way to do it. I just search online and trying to mess with the code but I got an error message saying that: "Compile error: Expected Function or variable"
Wonder if someone could point out the error or the correct way to do it?
Thank you!
I'm not sure this is the way to do it. I just search online and trying to mess with the code but I got an error message saying that: "Compile error: Expected Function or variable"
Code:
Sub Open_External_Workbook()
Dim open_Workbook As Workbook
Dim wb As Workbook
Workbooks.Open Filename:="C:\Users\Desktop\WorkWithExFile2.xlsm"
Set open_Workbook = Application.Workbooks.Open _
("C:\Users\Desktop\WorkWithExFile2.xlsm")
open_Workbook.SaveAs ("C:\Users\Desktop\test.xlsm")
Set wb = Workbooks.Open("C:\Users\Desktop\test.xlsm")
Application.Run wb.Name & "!" & proc_test
End Sub
Sub proc_test()
Worksheets("Sheet1").Range("A1").Value = "Ran proc_test"
End Sub
Wonder if someone could point out the error or the correct way to do it?
Thank you!