none
Using Common Dialog From Within Access 2010 64 bit

    Question

  • GetOpenFileName does not work in VBA under the 64 bit version of Access 2010.

    I want to use the CommonFileDialog to replace all the bits that don't work.

    What reference do I need so that VBA recognises the Common Dialog types.

    At present the statement

    Dim cfd As CommonOpenFileDialog

    results in a compiler error "User-defined type not defined"

     

    Wednesday, June 09, 2010 3:52 PM

Answers

  • I actually much suggest using the built in File dialog.

     

    It works with going back to 2007, and i think even perhaps 2003.

     

    You don't need any additonal code, and thus for 64 or 32, it will run without issues. (and it even works in runtime only). It don't have any refferences issues either.

     

    So, I see little need for api, or additional code with the built in filedialog.

     

    CODE:

    Dim f    As FileDialog

    Set f = Application.FileDialog(msoFileDialogFilePicker)

    f.Show

    MsgBox "file choose was " & f.SelectedItems(1)

     

    You can late bind if you wish:

     

    If you remove the reference to the 14.0 object library, then the following

    code will work without any references:

     

     

       Dim f    As Object

       Set f = Application.FileDialog(3)

       f.AllowMultiSelect = True

       f.Show

     

       MsgBox "file choosen = " & f.SelectedItems.Count

     

    Note that above works in the runtime also...

     

    Albert D. Kallal

    Edmonton, Alberta Canada

     

    • Marked as answer by infrazee Friday, June 11, 2010 5:11 AM
    Thursday, June 10, 2010 9:18 PM

All replies