Hi,
This is an interesting one...
I am just completing a fairly extensive project written in Excel for VBA and I have come across an anomaly that seems to make no sense at all.
To start with I'm using Excell 2002 (Yes I know but it's what the firm has got and I have to live with it
).
The problem is that the project ends with a series of instructions that saves the current workbook before exiting (Nothing unusual there). The code is as follows...
At another point in the project, an error checking routine displays a standard MsgBox as an error message as follows...
The problem is that sometimes, when the save routine runs, the file is saved, then, beyond all reason, the msgBox is displayed. Once the msgbox is cleared by the operator, the 'Application.Quit' instruction runs.
The thing is that at no time, during the running of the project, has the MsgBox been invoked and a 'Stop' instruction inserted before the line that invokes the msgBox makes no difference.
Also inserting a 'Stop' instruction prior to the 'Application.Quit' instruction breaks the routine as expected but the MsgBox isn't displayed even when the routine is resumed.
None of this makes any sense to me... does it ring any bells with anyone else...
Rob
This is an interesting one...
I am just completing a fairly extensive project written in Excel for VBA and I have come across an anomaly that seems to make no sense at all.
To start with I'm using Excell 2002 (Yes I know but it's what the firm has got and I have to live with it
The problem is that the project ends with a series of instructions that saves the current workbook before exiting (Nothing unusual there). The code is as follows...
Code:
Sub SaveAndExit()
Application.CutCopyMode = False
ActiveWorkbook.Save
Application.Quit
End Sub
At another point in the project, an error checking routine displays a standard MsgBox as an error message as follows...
Code:
Err2:
Vect = MsgBox("No xxxx. Do you wish to add a xxxx? (Y/N)", vbYesNo, "xxxx Prompt")
The problem is that sometimes, when the save routine runs, the file is saved, then, beyond all reason, the msgBox is displayed. Once the msgbox is cleared by the operator, the 'Application.Quit' instruction runs.
The thing is that at no time, during the running of the project, has the MsgBox been invoked and a 'Stop' instruction inserted before the line that invokes the msgBox makes no difference.
Also inserting a 'Stop' instruction prior to the 'Application.Quit' instruction breaks the routine as expected but the MsgBox isn't displayed even when the routine is resumed.
None of this makes any sense to me... does it ring any bells with anyone else...
Rob