George
Member
Hi all,
A simple sounding question that seems to be a lot more complicated to solve than I would have thought:
How do I stop workbook.open from running asynchronously?
What I mean by this is force excel to wait until the workbook it's opening has finished loading before moving on to the next line of code.
For reasons I can't quite comprehend it seems to work fine for me, but when anyone else on our network tries to run the code it throws up an error.
Below is a snippet of the code:
A simple sounding question that seems to be a lot more complicated to solve than I would have thought:
How do I stop workbook.open from running asynchronously?
What I mean by this is force excel to wait until the workbook it's opening has finished loading before moving on to the next line of code.
For reasons I can't quite comprehend it seems to work fine for me, but when anyone else on our network tries to run the code it throws up an error.
Below is a snippet of the code:
Code:
Public Sub test()
Dim OutputDocName As String
Dim MsgResponse As Integer
Dim wBook As Workbook
MsgResponse = MsgBox("Add to output?", vbYesNo)
If MsgResponse = vbYes Then
OutputDocName = "MasterFile"
'stop excel from asynchronously loading file here
Workbooks.Open Filename:=Left(ThisWorkbook.Path, Len(ThisWorkbook.Path) - 16) & "Staging_DoNotTouch\" & OutputDocName & ".xlsm"
ImportData OutputDocName, "Setup"
ImportData OutputDocName, "Monthly"
ImportData OutputDocName, "One Off"
ClientProjectList OutputDocName
Workbooks(OutputDocName).Close savechanges:=True
End If
End Sub