Hi Paul,
Sorry I should've been more clear. I am now appending this piece of code onto the piece of code I have that prompts the user to select a file. I want to have the workbook name saved in the "str" variable at the end but it's giving me some grief with the spaces still. Here is the full piece of code.
When I try to run this code choosing a file called "Commissions Data.xlsx" it only returns "Data.xlsx"
Sub Test2()
'Display a Dialog Box that allows to select a single file.
'The path for the file picked will be stored in fullpath variable
With Application.FileDialog(msoFileDialogFilePicker)
'Makes sure the user can select only one file
.AllowMultiSelect = False
'Filter to just the following types of files to narrow down selection options
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
'Show the dialog box
.Show
'Store in fullpath variable
Dim fullpath As String
fullpath = .SelectedItems.Item(1)
End With
Dim ar, str As String
ar = Split(fullpath)
str = "" & ar(UBound(ar))
MsgBox str
End Sub