Thread: [Solved] get file name without Path
View Single Post
 
Old 09-28-2006, 12:17 PM
Ziggy1 Ziggy1 is offline
Novice
 
Join Date: Sep 2006
Location: Ont, Canada
Posts: 8
Ziggy1
Default get file name without Path

Hello

I am using this code to select a file an run a macro, but the code returns the full path. How can I get just the filename? I need to use the same file name that was opened but the path will be different? do I need to parse or is there a method to return just the file name

Dim FileToOpen As String
Dim FileOpenName As String
Dim SaveName As String

' Set the default directory.
' Note: Substitute any existing directory.
Options.DefaultFilePath(Path:=wdDocumentsPath) = "\\10.3.16.243\9105_boh"




With Dialogs(wdDialogFileOpen)
On Error Resume Next
If .Display <> 0 Then
FileToOpen = WordBasic.FileNameInfo(.Name, 1)
Else
MsgBox "No file selected"
End If
End With



Documents.Open FileName:=FileToOpen, ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
Reply With Quote