S
Stephen Poley
I am developing a VPA procedure that needs to use two temporary copies
of the workbook supplied by the user. I create these with the following
code:
On Error GoTo KanGeenBestandOpslaan
ActiveWorkbook.SaveAs Filename:=Distmap & OutputBestand
ActiveWorkbook.SaveAs Filename:=Distmap & TempBestand
On Error GoTo 0
On Error GoTo KanBestandNietHeropenen
Workbooks.Open Filename:=Distmap & OutputBestand
On Error GoTo 0
If the two temporary files exist on the disk, the user is asked to
confirm that they can be overwritten; the procedure then runs correctly.
However, if the temporary files do NOT exist on the disk, either because
the tidy-up code at the end of the procedure has removed them on the
previous run (this is of course intended to be the normal situation) or
because I deleted them manually, then Excel hangs on the Open statement.
The file is in fact opened, but the next line of VBA is never executed
(I've tried both inserting a MsgBox, and placing a breakpoint), the
error-handling code is never reached, and no error message is generated.
Weirder still: if I place a breakpoint on the Open statement itself, the
breakpoint is reached; after Continue (F5) the procedure then runs
correctly!
The data workbook I am testing with itself contained a macro, and I
thought this might be related, but after removing the module (i.e. all
modules) this hang remains.
A colleague said that Excel has an occasional bug where it "forgets" to
remove a breakpoint, but after cutting the code, restarting Excel and
pasting the code back in, the problem remains.
I have also tried rebooting.
Suggestions please?
Am using Excel 2003, Dutch language, Windows XP
of the workbook supplied by the user. I create these with the following
code:
On Error GoTo KanGeenBestandOpslaan
ActiveWorkbook.SaveAs Filename:=Distmap & OutputBestand
ActiveWorkbook.SaveAs Filename:=Distmap & TempBestand
On Error GoTo 0
On Error GoTo KanBestandNietHeropenen
Workbooks.Open Filename:=Distmap & OutputBestand
On Error GoTo 0
If the two temporary files exist on the disk, the user is asked to
confirm that they can be overwritten; the procedure then runs correctly.
However, if the temporary files do NOT exist on the disk, either because
the tidy-up code at the end of the procedure has removed them on the
previous run (this is of course intended to be the normal situation) or
because I deleted them manually, then Excel hangs on the Open statement.
The file is in fact opened, but the next line of VBA is never executed
(I've tried both inserting a MsgBox, and placing a breakpoint), the
error-handling code is never reached, and no error message is generated.
Weirder still: if I place a breakpoint on the Open statement itself, the
breakpoint is reached; after Continue (F5) the procedure then runs
correctly!
The data workbook I am testing with itself contained a macro, and I
thought this might be related, but after removing the module (i.e. all
modules) this hang remains.
A colleague said that Excel has an occasional bug where it "forgets" to
remove a breakpoint, but after cutting the code, restarting Excel and
pasting the code back in, the problem remains.
I have also tried rebooting.
Suggestions please?
Am using Excel 2003, Dutch language, Windows XP