Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File open dialog box (2003)

    I wish to open an excel file that is in the same directory as the excel file that contains the code below. I have used the following code to create a file open dialog box:

    Dim AddressofFileToOpen As String
    ' Open the file dialog
    With Application.FileDialog(msoFileDialogOpen)
    .AllowMultiSelect = False
    .InitialFileName = ThisWorkbook.FullName
    .Show
    AddressofFileToOpen = .SelectedItems(1)
    End With

    However when the dialog box appears it only shows the file that holds the code, and all the other workbooks in the directory are hidden to me.

    Can somebody please advise whether I need to change a dialog box setting so as to see all the excel files that are available in the directory

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: File open dialog box (2003)

    Use ThisWorkbook.Path instead of ThisWorkbook.FullName.

    Note: to avoid an error message if the user cancels the dialog, I'd use

    If .Show Then
    AddressofFileToOpen = .SelectedItems(1)
    End If

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File open dialog box (2003)

    Hans

    Thanks for these very neat fixes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •