rodrigo_m_almeida
New Member
- Joined
- Jan 13, 2022
- Messages
- 42
- Office Version
- 2021
- Platform
- Windows
Good morning,
Could anyone help me with this ?
I would like to adapt this code I am using to select and open only one file instead of the folder...
Could anyone help me with this ?
I would like to adapt this code I am using to select and open only one file instead of the folder...
VBA Code:
Public Sub ABC123()
' Declare Variables
Dim xPathName, xFileName As String
' Browse File
Set FileDialog = Application.FileDialog(msoFileDialogFolderPicker)
FileDialog.Title = "Select Folder"
If FileDialog.Show = -1 Then
xPathName = FileDialog.SelectedItems(1)
Else
Exit Sub
End If
If Right(xPathName, 1) <> "\" Then xPathName = xPathName + "\"
' Search Extension
xFileName = Dir(xPathName & "*.xlsx")
' Open File
Workbooks.Open Filename:=xPathName & xFileName
End Sub