Open FileDialog in an application using VBA RRS feed

  • Question

  • Hello,
    I am working in IGSS environment which uses Microsoft Visual Basic 6.3
    (VBA: Retail 6.5.1054, Forms3: 11.0.8000)
    What i am trying to do, is make a program, where after clicking a button, a file dialog opens. In VBA, after adding reference to Microsoft Office 11.0 object library, i can create a variable of FileDialog type, but then i cant invoke method to return a FileDialog object. The method should be Application.FileDialog but it does not exist.

    Is it possible to get or create a FileDialog object in a different way, without using Application.FileDialog method?


    Monday, July 18, 2016 8:38 AM

All replies

  •    This will work in all office apps:

        Dim s As Variant
        Dim Res As Integer
        Dim dlgOpen As FileDialog
        Set dlgOpen = Application.FileDialog( _
        Res = dlgOpen.Show
        If Not Res = 0 Then
            For Each s In dlgOpen.SelectedItems  'There is only one
                MsgBox s
                'do something with s
        End If  

    But if the specific application you are using does not offer that method, then you will need to use another option, like the FileSystemObject from MS scripting.

    Monday, July 18, 2016 4:35 PM
  • That's exactly the problem. The application I work with does not offer this method, so i would need other way to create or to get FileDialog object. I will look into FSO more deeply, thanks!
    By the way, does anything else come to your mind? Would appreciate any clues about File dialogs outside of Office.
    Tuesday, July 19, 2016 6:43 AM
  • Okay, anyone having the same problem as me, can create an excel object (CreateObject("Excel.Application") and use the method FileDialog via the created object. I can't use it since it requires excel to be installed. Probably i'll have to stick to an inputbox.
    Tuesday, July 19, 2016 1:11 PM