Results 1 to 3 of 3

Thread: Macro to Browser for file in folder

  1. #1
    Join Date
    Oct 2017

    Macro to Browser for file in folder

    Is there a simple way I can create a click on and have it open a folder browser that lets me go to the folder and select the file? That sounds simple, how would I create a macro or VBA that opens a browser?

  2. #2
    Join Date
    Oct 2006
    Maitland NSW Australia
    I use, the following code that I found on the internet, to store the location of a file into a control (field) on a form the control name is display_0005. Replace display_0005 with your control (field) name that you are using on the form.

    Private Sub display_0005_Click()
    On Error GoTo Err_display_0005_Click
    'Declare a variable as a FileDialog object.
        Dim fd As FileDialog
        'Create a FileDialog object as a File Picker dialog box.
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        'Declare a variable to contain the path
        'of each selected item. Even though the path is aString,
        'the variable must be a Variant because For Each...Next
        'routines only work with Variants and Objects.
        Dim vrtSelectedItem As Variant
        'Use a With...End With block to reference the FileDialog object.
        With fd
            'Allow the user to select multiple files.
            .AllowMultiSelect = True
            'Use the Show method to display the File Picker dialog box and return the user's action.
            'If the user presses the button...
            If .Show = -1 Then
                'Step through each string in the FileDialogSelectedItems collection.
                For Each vrtSelectedItem In .SelectedItems
                    'vrtSelectedItem is aString that contains the path of each selected item.
                    'You can use any file I/O functions that you want to work with this path.
                    'This example displays the path in a message box.
                    Me!display_0005 = vrtSelectedItem
            'If the user presses Cancel...
            End If
        End With
        'Set the object variable to Nothing.
        Set fd = Nothing
        Exit Sub
        MsgBox Err.Description
        Resume Exit_display_0005_Click
    End Sub

  3. #3
    Join Date
    Nov 2017
    Yep go in options am click at on click open option!

Posting Permissions

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