Q How can I tell if an MDL application is loaded using MicroStation VBA?

Questions similar to this, posed by MDL and VBA developers, appear on the Bentley Discussion Groups, typically the VBA discussion group.

A MicroStation VBA has no intrinsic way to find if a particular MDL application is loaded, but you can use an MDL function mdlSystem_getTaskStatistics. I've wrapped it in a VB function IsMdlLoaded. An example of its use follows …

Option Explicit
' ---------------------------------------------------------------------
'   modMDL shows how to tell if a named MDL application is loaded
' ---------------------------------------------------------------------
'   Notice:
'
'   MicroStation VBA code provided by LA Solutions at no cost and with
'   no license requirement as part of the MDL example project
'
'   This software is provided with no warranty and no declaration of
'   fitness for any purpose.  No support is provided.
'   You may use this software and copy it to others inside or outside
'   your organisation provided that this notice is retained in full.
'
'   Copyright © 2005 LA Solutions Ltd
' ---------------------------------------------------------------------
'   MDL Function Prototypes
' ---------------------------------------------------------------------
Declare Function mdlSystem_getTaskStatistics Lib "stdmdlbltin.dll" (ByVal statisticsP As Long, ByVal taskIdP As String) As Long
' ---------------------------------------------------------------------
Sub Main() Dim mdlapp As String mdlapp = "IGEN" If (IsMdlLoaded(mdlapp)) Then Debug.Print "'" & mdlapp & "' is loaded" Else Debug.Print "'" & mdlapp & "' is not loaded" End If End Sub
' ---------------------------------------------------------------------
Function IsMdlLoaded(appName As String) As Boolean IsMdlLoaded = False On Error GoTo err_IsMdlLoaded If (0 = mdlSystem_getTaskStatistics(0, appName)) Then IsMdlLoaded = True End If Exit Function err_IsMdlLoaded: MsgBox "Error no. " & CStr(Err.Number) & ": " & Err.Description, vbCritical Or vbOKOnly, "IsMdlLoaded Error" End Function