Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting VBA snippet to VBScript

Status
Not open for further replies.

dmikester1

Programmer
Joined
Oct 12, 2010
Messages
2
Location
US
I recorded a macro in Word and collected the VBA code. I would like to convert it to VBScript so I can run it as a stand-alone script.

Here is the VBScript I wrote:
Code:
dim filesys, pathstring
set filesys=CreateObject("Scripting.FileSystemObject")
pathstring = filesys.GetAbsolutePathName("c:")
Msgbox pathstring

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(pathstring & "\LOTO.rtf")

And the VBA I copied:
Code:
ActiveDocument.SaveAs FileName:="LOTO.txt", FileFormat:=wdFormatText, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False, Encoding:=1252, InsertLineBreaks:=False, AllowSubstitutions:=False _
        , LineEnding:=wdCRLF

Can someone help me out?
Thanks
Mike
 
Use simply this:
objDoc.SaveAs "LOTO.txt", 2 '2=wdFormatText

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you very much. That worked perfect!
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top