Control Unexpectedly returns to the calling procedure

S

Steve

I'm using Office 2000 and 2003.
Following is an extraction of the code I'm using. The issue is when

"If ((Answer = vbCancel) Or (Answer = "") Or (Answer = "X")) Then Call
ConfirmExit" is executed in GetSaveFilename subroutine and Answer does = "X"
the ConfirmExit subroutine is never called and control immediately returns to
the MainCapture procedure. By chance is confirm or ConfirmExit reserved words
in VBA? I'm puzzled why this keeps happening and have wasted too much time on
what should be a very simple procedure. Any assistance would be greatly
appreciated.

Sub MainCapture()

Call GetSaveFilename
If exitproc Then Exit Sub
....
....
End Sub

Sub GetSaveFilename()

filename = ""
WindowTitle = "Get Filename"

Do
Answer = InputBox("Enter filename to save survey information." & vbCr & vbCr
& "Hit Enter, Cancel or type X or x to exit.", WindowTitle)

If Answer = "x" Then Answer = "X"
If ((Answer = vbCancel) Or (Answer = "") Or (Answer = "X")) Then Call
ConfirmExit
If exitproc Then Exit Sub
....
....
Loop
End Sub

Sub ConfirmExit()

exitproc = False
confirm = MsgBox("Select ""Yes"" to confirm termination" & vbCr & vbCr & _
"Select ""No"" to continue processing.", vbYesNo _
vbDefaultButton2, WindowTitle)
If confirm = vbYes Then exitproc = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top