I am using the msoFileDialogFolderPicker to return a path when a user wants to deposit a report in a specific folder.
A custom form (ufSelRepType) shows up in the macro in cases where the default save location already has an output file or when the user does not wish to save to the default location. The custom form specifies a few common report save locations and gives the option to select an alternate location. Clicking button cmdCustom does the following:
Private Sub cmdCustom_Click()
Application.FileDialog(msoFileDialogFolderPicker).Show
Me.Tag = CurDir
Me.Hide
End Sub
The code in the macro to handle the form output is simple:
strSavePath = ufSelRepType.Tag
Selecting a folder, the string is always returned without a trailing "\". However, if a drive root is selected (we use mapped drives to our file server and so while this case may be rare, it is not an inconcievable scenario) the string returned ends with a "\".
How might I go about checking for the trailing "\" and handling it?
UPDATE: Per solution below, this is the new code for the form control cmdCustom:
Private Sub cmdCustom_Click()
Dim strFolderPath As String
'Getting save folder
Application.FileDialog(msoFileDialogFolderPicker).Show
strFolderPath = CurDir
'Checking that path ends in \
If Right(strFolderPath, 1) = "\" Then
GoTo Complete
Else:
strFolderPath = strFolderPath & "\"
GoTo Complete
End If
Exit Sub
Complete:
Me.Tag = strFolderPath
Me.Hide
Exit Sub
End Sub