I have code that extracts the full path of a file, minus the extension, and I'm trying to modify it to only store the name of the file, once again without the extension.
Sub ShowFilename()
Dim pathName As String
With ActiveDocument
If Len(.Path) = 0 Then
.Save
End If
If Right(.Name, 1) = "x" Then
pathName = Left$(.FullName, (Len(.FullName) - 5))
Else
pathName = Left$(.FullName, (Len(.FullName) - 4))
End If
End With
MsgBox pathName
End Sub
This displays C:\Users\test, and the document's name is test.docm. How can I modify this to only display the filename? Do I need to split the string along \ and extract the last part?