Howard Kaikow
01-09-2005, 03:32 AM
I have a VB 6 ActiveX DLL that contains 12 Forms.
The DLL is used by Word.
A toolbar/menu starts macros that invoke the 6 main Forms.
Each Form has a QueryUnload event similar to the one given below.
Only 1 of the Forms has the specific Msgbox listed below. The others have
quite different text.
However, yesterday, something very odd started happening.
I would start a macro, and use the appropriate buttons to close the Form.
No problem doing this.
However, when I then exit from Word, somehow, this causes the code below to
be invoked a Form that was not even used during the current Word session.
The message below is issued, even tho the Form was not used and the Close
box was not used with any Form.
After I respond to the Msgbox, less than a minute later, I get a nasty
screen stating that Word must close and asking whether I wish to send a
report to Microsoft.
The same thing happens no matter which Form is used. As far as I know the
Form that contains the particular QueryLoad event is NOT being loaded.
What could cause this behavior?
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If UnloadMode = vbFormControlMenu Then
Cancel = 1
MsgBox "Please use the Exit tab to close the Form", _
vbInformation + vbOKOnly, "Close button cannot be used to close
the Form"
Else
Cancel = 0
End If
End Sub
The DLL is used by Word.
A toolbar/menu starts macros that invoke the 6 main Forms.
Each Form has a QueryUnload event similar to the one given below.
Only 1 of the Forms has the specific Msgbox listed below. The others have
quite different text.
However, yesterday, something very odd started happening.
I would start a macro, and use the appropriate buttons to close the Form.
No problem doing this.
However, when I then exit from Word, somehow, this causes the code below to
be invoked a Form that was not even used during the current Word session.
The message below is issued, even tho the Form was not used and the Close
box was not used with any Form.
After I respond to the Msgbox, less than a minute later, I get a nasty
screen stating that Word must close and asking whether I wish to send a
report to Microsoft.
The same thing happens no matter which Form is used. As far as I know the
Form that contains the particular QueryLoad event is NOT being loaded.
What could cause this behavior?
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If UnloadMode = vbFormControlMenu Then
Cancel = 1
MsgBox "Please use the Exit tab to close the Form", _
vbInformation + vbOKOnly, "Close button cannot be used to close
the Form"
Else
Cancel = 0
End If
End Sub