Share via

VBA Excel - Empty Folder Name

Anonymous
2024-02-06T11:06:58+00:00

Dear All,

with this code I'm able to open the below FileDialogFolderPicker which allows to access the files of my computer:

    With Application.FileDialog(msoFileDialogFolderPicker)
        .InitialFileName = sInitialFolder
        If .Show = -1 Then
            lstCodeFile.Clear
            sFolder = .SelectedItems(1)
            txtCodeFileDirectory = sFolder
        Else
            Exit Sub
        End If
    End With

Any way to automatically fill the "Folder name" box with the value of the InitialFolder? (should be "Code")

Thanks

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2024-02-06T18:02:04+00:00

Remove the trailing backslash.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-02-06T16:10:21+00:00

    If the InitialFileName is "D:\MyPC\05 - Tool*Code*" the Folder name" box should be "Code" and not empty

    ![](https://learn-attachment.microsoft.com/api/attachments/527c4321-31ba-4ce2-b388-6c35bf410116?platform=QnA

    Was this answer helpful?

    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2024-02-06T15:52:19+00:00

    Make a new file

    Run the code below

    Where is the issue?

    Andreas.

    Sub Test()
    With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = "qwe"
    .Show
    End With
    End Sub

    Was this answer helpful?

    0 comments No comments