Your Active Document project may contain forms as well as
UserDocument objects because you might want to display these forms as part of the functioning
of your Active Document application. There are two situations when you can't display
modeless forms, however:
-
An Active Document project compiled as a DLL cannot use modeless forms. Only Active
Document EXE projects can use modeless forms at all.
-
Some container types will not support modeless Forms in any type of Active Document
regardless of whether the underlying application is an EXE or DLL. At the present writing,
for instance, Internet Explorer 4.0 and components of MS Office 97 and higher will
support modeless Forms in Active Document EXEs, but Internet Explorer 3.x will not
(it causes a runtime error). Your UserDocument's code can determine
whether or not its current container supports modal forms by checking the value of
App.NonModalAllowed. If its value is True, you can go ahead and display a
form modelessly. Otherwise, better not display the form or display it as a modal form (see
Listing 14.10).
LISTING 14.10
DETERMINING WHETHER IT'S OK TO DISPLAY
A FORM MODELESSLY
Private Sub cmdShowData_Click()
If App.NonModalAllowed Then
frmData.Show vbModeless
Else
frmData.Show vbModal
End If
End Sub
As a general rule, it's safest to always display forms modally even in an ActiveX
EXE.