Share via

Why code is functioning in one PC but not another ?

Anonymous
2025-01-06T07:50:32+00:00

Question is about Excel VBA function FileDialog.InitialFileName.

Both PC:s have Win11 updated to last version and Office 2021 (Excel version is 2108)

In one PC selection of File is from the specified catalog.

In other PC .InitialFileName has no effect and selection is started allways from catalog C:/Users/xx/Desktop

Here is the code

Dim fd As Office.FileDialog 

Dim XXExport As String 

Set fd = Application.FileDialog(msoFileDialogFilePicker) 

XXExport = "" 

With fd 

    .Filters.Clear 

    .Title = "Valitse Excel file" 

    .AllowMultiSelect = False 

    .InitialFileName = "C:\Users\xx\Downloads\" 

    If .Show = True Then 

        XXExport = .SelectedItems(1) 

    End If 

End With
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