VBA SourceName method

I'm using VBA to read a text file made of files paths (path & name). I'm opening them in word and trying to resave them into .txt format for notepad/wordpad. There is no easy way to be able to find the last "\" and then use that to take all the text after it.

example: "C:\my docs\this file.doc" i would want the "this file" portion of the text


I found what seems to be a useful method (sourcename) but have no idea how to implement it

If f1 = fso.FileExists(file) Then
Documents.Open filename:=line, ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto, XMLTransform:="" 'open file

** here is where i'm looking to get just the file name**
**temp is the variabel below that should hold the file name**

ActiveDocument.SaveAs filename:=temp + ".txt", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=True, AllowSubstitutions:=True, _
LineEnding:=wdCRLF 'saves file in chosen format

ActiveDocument.Close 'close file
End If

any help would be very much appreciated

[1603 byte] By [cmwith] at [2007-12-22]
# 1
These forums are intended for VB.Net development and your description describes using VBA (Visual Basic For Applications) which is the internal language within many of the Office Products.

You may find more assistance in following which specifically deals with VBA / MS Office development.

VBA specific forum

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=74&SiteID=1

Office Automation: office.developer.automation newsgroup

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.office.developer.automation&lang=en&cr=US

Or the Office Newgroups

http://www.microsoft.com/office/community/en-us/default.mspx?d=1

Hope these help....

spotty at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...