mattygriff
Programmer
Hi all,
I need to roll out some changes to some template spreadsheets I developed recently.
My plan was to write up an Excel macro that would ask the user to navigate to the workbook. My macro would then open the workbook, change the formulae that need changing and save the workbook back in the same location.
The problem I have is that the workbooks that need changing have macros in them that automatically run whenever they are opened and that is a bit of a problem so I need, if possible, to open them without running the macros.
I have searched about online and currently have the following :
strFileToOpen is provided from a separate function where the user navigates to the workbook that needs to be updated.
I thought this code would open the second workbook in a separate instance of Excel so that I could disable the macros but that doesn't seem to be happening. I appear to be getting both files in the same instance although I can't actually see the second workbook at all.
Does anyone have any suggestions? I am using Excel 2007 if that makes any difference.
Thanks, in advance.
I need to roll out some changes to some template spreadsheets I developed recently.
My plan was to write up an Excel macro that would ask the user to navigate to the workbook. My macro would then open the workbook, change the formulae that need changing and save the workbook back in the same location.
The problem I have is that the workbooks that need changing have macros in them that automatically run whenever they are opened and that is a bit of a problem so I need, if possible, to open them without running the macros.
I have searched about online and currently have the following :
Code:
Sub OpenFileForChanges(strFileToOpen As String)
Dim NewWB As Object ' Variable to hold reference to new Excel instance
Set NewWB = GetObject(strFileToOpen)
NewWB.Application.EnableEvents = False
End Sub
strFileToOpen is provided from a separate function where the user navigates to the workbook that needs to be updated.
I thought this code would open the second workbook in a separate instance of Excel so that I could disable the macros but that doesn't seem to be happening. I appear to be getting both files in the same instance although I can't actually see the second workbook at all.
Does anyone have any suggestions? I am using Excel 2007 if that makes any difference.
Thanks, in advance.