How to "Browse For A Folder" and not using "shell32.dll"

Hi there,

Is there another way to browse for a folder in Microstation VBA apart from using shell.application?

By this method it is not possible to set a default path.

Thanks,

Elahe

 

 

  • BTW these are my codes:

    Dim objShell As Object

    Dim objFolder As Object

    Dim DGNDirName As String

     Set objShell = CreateObject("Shell.Application")

    Set objFolder = objShell.BrowseForFolder(0, "Please select a folder", BIF_NEWDIALOGSTYLE)

    If (Not objFolder Is Nothing) Then

           On Error Resume Next

    If IsError(objFolder.Items.Item.Path) Then DGNDirName = CStr(objFolder): GoTo GotIt

           On Error GoTo 0

    DGNDirName = objFolder.Items.Item.Path

    Else

        If txtDGNFolder.Text = "" Then

               MsgBox "Please Select A Path": GoTo Xit

           Else

               GoTo Xit

           End If

       End If

    GotIt:

       txtDGNFolder.Text = DGNDirName

    Xit:

       Set objFolder = Nothing

       Set objShell = Nothing

  • Folder Browser

    Unknown said:
    Is there a way to browse for a folder in Microstation VBA

    For reasons known only to itself, Microsoft failed to include the most frequently-used dialogs with VBA — the Windows Common Dialogs. The Windows Common Dialogs include File Open, File Save As and Browse for Folder and a few others.

    Nevertheless, we show you how to implement File Open and File Save As dialogs.

    Another article discusses a FolderBrowser ActiveX component. FolderBrowser is freeware.

    FolderBrowser ActiveX component

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Thanks John,

    As usual you are a life saver. Interesting that you have mentioned it because the first time I wanted to write some code with VBA I was surprised that there is no CommonDialog in my toolbox?

    I also tried to utilise FileDialog object by adding Excel library as reference and I end up with runtime errors.

    Anyway the ActiveX I got from your website works well.

    Cheers,

    Elahe