ERROR

Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property page

Last Published: April 26, 2020

Error Message

When attempting to show a modeless form implemented within a Visual Basic ActiveX DLL, the following error may occur:

Error:   
Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property page

Cause

At ArcGIS 9.x, Visual Basic for Applications (VBA) is not automatically initialized when ArcGIS applications start. It is only initialized if there is at least one VBA subroutine that handles an event; for example, any document event or those events associated with UI Controls. The change was made as part of an overall effort to improve the performance and resource utilization of ArcGIS. At ArcGIS 9.x, many subsystems such as extensions, toolbars and dockable windows are now loaded only when they are needed.

Deferring the initialization of VBA when an ArcGIS application starts can cause modeless forms implemented in Visual Basic ActiveX DLLs to fail, since they rely on VBA being fully initialized for modeless support to be enabled. When an attempt is made to show a VB dialog modelessly, it fails.

Microsoft documents a known issue where modeless forms in Visual Basic ActiveX DLLs should not be utilized to display modelessly. More information is available in the Related Information section below. VB modeless forms also suffer from other problems such as focus and z-order nonconformities. Modeless forms implemented in other development environments including C++, C#, Delphi and VB.NET do not suffer from this problem.

Solution or Workaround

Instead of requiring that all users load VBA at application startup in anticipation that a VB modeless form may be required, the following solutions are available to allow modeless forms in Visual Basic ActiveX DLLs to appear.
  • Use modal forms instead as suggested in Microsoft Knowledge Base Article - 247791.
  • Port the VB code, or that portion needing modeless support, to any of the other popular development languages that do support modeless forms without the presence of VBA.
  • Modify the Visual Basic form to use the ModelessFrame object. The ModelessFrame object was added to ArcGIS 9.0 to provide Visual Basic developers with a way to implement modeless windows in ArcGIS without requiring VBA to initialize, and is essentially a wrapper around ordinary VB forms. The ModelessFrame object requires minimal changes to existing VB code to take advantage of it, manages the Z order of modeless forms so that they behave correctly with respect to application focus, and ensures that the window minimizes and restores appropriately with the ArcGIS application.
  • Force VBA to load on startup with a registry setting. VBA can be made to load every time the application is started by setting a value in the current users registry settings. Add one or more of the following REG_DWORD keys for each ArcGIS application that requires force VBA loading:
    Warning:
    The instructions below include making changes to essential parts of your operating system. It is recommended that you backup your operating system and files, including the registry, before proceeding. Consult with a qualified computer systems professional, if necessary.
    
    Esri cannot guarantee results from incorrect modifications while following these instructions; therefore, use caution and proceed at your own risk.

    HKEY_CURRENT_USER\Software\ESRI\ArcMap\Settings\PreloadVBA=1
    HKEY_CURRENT_USER\Software\ESRI\ArcCatalog\Settings\PreloadVBA=1
    HKEY_CURRENT_USER\Software\ESRI\ArcScene\Settings\PreloadVBA=1
    HKEY_CURRENT_USER\Software\ESRI\ArcGlobe\Settings\PreloadVBA=1

    Since this is a current user setting, when a new user logs in and starts ArcMap the registry key does not exist and VBA is not loaded. If PreloadVBA has a value of 0; VBA is not loaded when ArcMap starts. If PreloadVBA has a value of 1; VBA is loaded when ArcMap starts.

Article ID:000006706

Software:
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic