The DoWBUpdate routine is called from a command button on
a sheet.
When I step through the code in the debugger...all works
fine. When I just let the code execute, it never returns
from the OpenFiles call. Specifically...I have put msgbox
surrounding the workbook.open and when I just let the code
run, it does not return.
Yes, the WB I am opening does have a workbook.open event.
However, I have executed this code hundreds of times with
problems as I open and close this WB several times a day. And, when I step through this WB.open code, it works
fine.
sub DoWBUpdate()
dim WBtoUpdate as string
Dim theFile As Workbook
Dim theTemplate As Workbook
WBtoUpdate =frmOpenWorkbooks.lstOpenWorkbooks.Value
Application.DisplayAlerts = True
OpenFiles "Escapes.xls", WBToUpdate, TempEscapes
Set theFile = Workbooks(WBtoUpdate)
{rest removed}
end sub
Sub OpenFiles(TempType As String, theFile As String,
theTemp As String)
Dim Destination As String
Destination = Workbooks(theFile).Path & "\" & theTemp
Template = PathToTempType & TemplateType
If TempFileExists(Destination) Then
Kill Destination
End If
' copy a new template file into working directory
FileCopy Template, Destination
On Error GoTo 0
Workbooks.Open Destination, updateLinks:=False
end sub
.
a sheet.
When I step through the code in the debugger...all works
fine. When I just let the code execute, it never returns
from the OpenFiles call. Specifically...I have put msgbox
surrounding the workbook.open and when I just let the code
run, it does not return.
Yes, the WB I am opening does have a workbook.open event.
However, I have executed this code hundreds of times with
problems as I open and close this WB several times a day. And, when I step through this WB.open code, it works
fine.
sub DoWBUpdate()
dim WBtoUpdate as string
Dim theFile As Workbook
Dim theTemplate As Workbook
WBtoUpdate =frmOpenWorkbooks.lstOpenWorkbooks.Value
Application.DisplayAlerts = True
OpenFiles "Escapes.xls", WBToUpdate, TempEscapes
Set theFile = Workbooks(WBtoUpdate)
{rest removed}
end sub
Sub OpenFiles(TempType As String, theFile As String,
theTemp As String)
Dim Destination As String
Destination = Workbooks(theFile).Path & "\" & theTemp
Template = PathToTempType & TemplateType
If TempFileExists(Destination) Then
Kill Destination
End If
' copy a new template file into working directory
FileCopy Template, Destination
On Error GoTo 0
Workbooks.Open Destination, updateLinks:=False
end sub
.