T
Trefor
I am trying to write a macro that will check to see if a newer version of the
workbook that is being run exists. If it does, my thought was to pass control
to a second workbook, close the first, copy/update the first workbook and
restart the first workbook and finally close out the second.
While I understand how to run a macro in another workbook, if I close the
first workbook the second workbook macros just stop. Below is my code
example, any ideas? Or indeed is there a much smarter way to do this? Because
of course this will cause the Enable macro's message several times.
In Workbook1:
Sub Start()
Workbooks.Open Filename:="Workbook2.xls"
Run "Workbook2.xls" & "!MyMacro2", param1, param2, param3
ThisWorkbook.Close SaveChanges:=False
End Sub
Sub MyMacro1()
' continue doing stuff
End Sub
In Workbook2:
Sub MyMacro2(param1, param2, param3)
' Do stuff
Workbooks.Open Filename:="Workbook1.xls"
Run "Workbook1.xls" & "!MyMacro1"
ThisWorkbook.Close SaveChanges:=False
End Sub
workbook that is being run exists. If it does, my thought was to pass control
to a second workbook, close the first, copy/update the first workbook and
restart the first workbook and finally close out the second.
While I understand how to run a macro in another workbook, if I close the
first workbook the second workbook macros just stop. Below is my code
example, any ideas? Or indeed is there a much smarter way to do this? Because
of course this will cause the Enable macro's message several times.
In Workbook1:
Sub Start()
Workbooks.Open Filename:="Workbook2.xls"
Run "Workbook2.xls" & "!MyMacro2", param1, param2, param3
ThisWorkbook.Close SaveChanges:=False
End Sub
Sub MyMacro1()
' continue doing stuff
End Sub
In Workbook2:
Sub MyMacro2(param1, param2, param3)
' Do stuff
Workbooks.Open Filename:="Workbook1.xls"
Run "Workbook1.xls" & "!MyMacro1"
ThisWorkbook.Close SaveChanges:=False
End Sub