Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-28-2006, 12:17 PM
Ziggy1 Ziggy1 is offline
Novice
get file name without Path
 
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
truncating path or renaming audio file to play in powerpoint rbookend PowerPoint 0 05-02-2006 03:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft