I'm trying to remove a name of a specific file from its directory name, it's not the first time I've done it and I remember using the "Unbound" function last time but instead of the program returning the name to me of the specific file it is returning the number of the field corresponding to the file (5 in this case), can someone help me?
Code:
Code:
VBA Code:
Private Sub bt_file_Click()
Dim fd As Office.FileDialog
Dim strFile As String, strFile_extract() As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.Filters.Clear
.Filters.Add "Excel Files", "*.xlsm", 1
.Title = "Choose an Excel file"
.AllowMultiSelect = False
.InitialFileName = "C:\VBA Folder"
If .Show = True Then
strFile = .SelectedItems(1)
strFile_extract = Split(strFile, "\")
OtherBookPath = UBound(strFile_extract)
MsgBox OtherBookPath
End If
End With
Workbooks.Open Filename:=OtherBookPath
End Sub