VBA - Excel Browse File to Open RRS feed

  • Question

  • How can I create a dynamic browse file to open excel spreadsheet on your documents.
    Tuesday, January 1, 2013 10:52 AM


  • The line


    will display the Open dialog. Alternatively, you can ask the user to select a file, you can do what you want with the filename in your code:

    Sub Test()
        Dim strFile As String
        strFile = Application.GetOpenFilename("Excel workbooks,*.xls*")
        If strFile = "False" Then
            ' the user clicked Cancel
            ' the user selected a file; its path+name is in strFile
        End If
    End Sub

    Please note that GetOpenFilename does *not* open the file, it merely gives you the name of the selected file.

    Regards, Hans Vogelaar

    Tuesday, January 1, 2013 10:58 AM