FileDialog in OpenCities Map via VBA?

Is it possible to open a FileDialog in OpenCities vba?  

Asking for a friend...

Parents
  • Inspired by this thread, I crafted the following VBA which should work for OpenCities Map CONNECT Edition 64-bit releases.

    Option Explicit
    
    Private Const OK_BUTTON As Long = 0
    Private Const CANCEL_BUTTON As Long = 1
    Private Const ERROR_STATUS As Long = 32768
    
    Declare PtrSafe Function mdlDialog_fileOpen Lib "stdmdlbltin.dll" (ByVal fileName As String, _
        ByVal rFileH As Long, ByVal resourceld As Long, ByVal suggestedFileName As String, _
        ByVal filterString As String, ByVal defaultDirectory As String, ByVal titleString As String) As Long
        
    Declare PtrSafe Sub mdlOutput_status Lib "stdmdlbltin.dll" (ByVal pMessage As String)
    
    Sub FileOpen()
        
        Dim strFilePath As String
        Dim strFileFolder As String
        Dim strFileName As String
        Dim lngResourceFileHandle As Long
        Dim lngResourceId As Long
        Dim retVal As Long
        Dim strMessage As String
        
        strFilePath = Space(255)
        retVal = mdlDialog_fileOpen(strFilePath, lngResourceFileHandle, lngResourceId, "", "*.dgn", "MS_DEF", "Open File")
        
        Select Case retVal
        Case OK_BUTTON
            strFilePath = Left(strFilePath, Len(Trim(strFilePath)) - 1)
            strFileFolder = Trim(Left(strFilePath, InStrRev(strFilePath, "\", , vbTextCompare) - 1))
            strFileName = Trim(Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\")))
            
            strMessage = "File Path: " + strFilePath + vbCr + _
                "File Folder: " + strFileFolder + vbCr + _
                "File Name: " + strFileName
    
            MsgBox strMessage, , "Selected File"
            Debug.Print strMessage
            mdlOutput_status strMessage
        Case CANCEL_BUTTON
            MsgBox "No File Selected."
        Case ERROR_STATUS
            MsgBox "Error occurred while Dialog Box was being created."
        End Select
    
    End Sub
    

    Regards,

    Jeff Bielefeld [Bentley]



Reply
  • Inspired by this thread, I crafted the following VBA which should work for OpenCities Map CONNECT Edition 64-bit releases.

    Option Explicit
    
    Private Const OK_BUTTON As Long = 0
    Private Const CANCEL_BUTTON As Long = 1
    Private Const ERROR_STATUS As Long = 32768
    
    Declare PtrSafe Function mdlDialog_fileOpen Lib "stdmdlbltin.dll" (ByVal fileName As String, _
        ByVal rFileH As Long, ByVal resourceld As Long, ByVal suggestedFileName As String, _
        ByVal filterString As String, ByVal defaultDirectory As String, ByVal titleString As String) As Long
        
    Declare PtrSafe Sub mdlOutput_status Lib "stdmdlbltin.dll" (ByVal pMessage As String)
    
    Sub FileOpen()
        
        Dim strFilePath As String
        Dim strFileFolder As String
        Dim strFileName As String
        Dim lngResourceFileHandle As Long
        Dim lngResourceId As Long
        Dim retVal As Long
        Dim strMessage As String
        
        strFilePath = Space(255)
        retVal = mdlDialog_fileOpen(strFilePath, lngResourceFileHandle, lngResourceId, "", "*.dgn", "MS_DEF", "Open File")
        
        Select Case retVal
        Case OK_BUTTON
            strFilePath = Left(strFilePath, Len(Trim(strFilePath)) - 1)
            strFileFolder = Trim(Left(strFilePath, InStrRev(strFilePath, "\", , vbTextCompare) - 1))
            strFileName = Trim(Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\")))
            
            strMessage = "File Path: " + strFilePath + vbCr + _
                "File Folder: " + strFileFolder + vbCr + _
                "File Name: " + strFileName
    
            MsgBox strMessage, , "Selected File"
            Debug.Print strMessage
            mdlOutput_status strMessage
        Case CANCEL_BUTTON
            MsgBox "No File Selected."
        Case ERROR_STATUS
            MsgBox "Error occurred while Dialog Box was being created."
        End Select
    
    End Sub
    

    Regards,

    Jeff Bielefeld [Bentley]



Children
No Data