I'm trying to write a routine in a "control" workbook" which will modify an existing workbook without it being visible.
If I open the file within the existing Excel instance, application.visible=true also hided the "control" workbook.
If I create a second instance of Excel and open the exisitng workbook in that, I can't stop the macros from running in that workbook.
My code is:
Sub Macro2()
Dim xlApp As Object
Set xlApp = CreateObject("excel.application")
With xlApp
.EnableEvents = False
.Workbooks.Open Filename:= _
"C:\Documents and Settings\ianc\My Documents\Template Prep\II checklist.xlt", _
UpdateLinks:=0
'
' More code here
'
.EnableEvents = True
End With
End Sub
The .EnableEvents = False should stop the macros in II Checklist.xlt from running.
If I open II Checklist.xlt in the existing Excel instance, the EnableEvents command works as expected, but the Visible command also hides the "control" workbook
Sub Macro2()
Application.Visible =False
Application.EnableEvents = False
Workbooks.Open Filename:= _
etc.
Any ideas where I'm going wrong.
Ian
If I open the file within the existing Excel instance, application.visible=true also hided the "control" workbook.
If I create a second instance of Excel and open the exisitng workbook in that, I can't stop the macros from running in that workbook.
My code is:
Sub Macro2()
Dim xlApp As Object
Set xlApp = CreateObject("excel.application")
With xlApp
.EnableEvents = False
.Workbooks.Open Filename:= _
"C:\Documents and Settings\ianc\My Documents\Template Prep\II checklist.xlt", _
UpdateLinks:=0
'
' More code here
'
.EnableEvents = True
End With
End Sub
The .EnableEvents = False should stop the macros in II Checklist.xlt from running.
If I open II Checklist.xlt in the existing Excel instance, the EnableEvents command works as expected, but the Visible command also hides the "control" workbook
Sub Macro2()
Application.Visible =False
Application.EnableEvents = False
Workbooks.Open Filename:= _
etc.
Any ideas where I'm going wrong.
Ian