Sign in to follow this  
Followers 0
Zoroxeus

Trying to save as TEXT

6 posts in this topic

Hello

Trying to save as a "Text" file...

$text = ObjCreate ("Word.Application")

$text.visible = False

$text.Documents.Add

$text.Selection.TypeText("This is a")

$text.ChangeFileOpenDirectory (@DesktopDir)

'$text.i_Format=5

$text.Activedocument.SaveAs("test.txt")

$text.Application.Quit

not sure what i am missing ?

Thanks

Share this post


Link to post
Share on other sites



The SaveAs method requires an additional parameter for specifying the file type:

$text = ObjCreate ("Word.Application")
$text.visible = False
$text.Documents.Add
$text.Selection.TypeText("This is a")
$text.ChangeFileOpenDirectory (@DesktopDir)
;$text.i_Format=5
$text.Activedocument.SaveAs("test.txt", 2)
$text.Application.Quit

The number 2 corresponds to the Word VBA constant wdFormatText, which tells Word to save the file as text.

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The SaveAs method requires an additional parameter for specifying the file type:

$text = ObjCreate ("Word.Application")
$text.visible = False
$text.Documents.Add
$text.Selection.TypeText("This is a")
$text.ChangeFileOpenDirectory (@DesktopDir)
;$text.i_Format=5
$text.Activedocument.SaveAs("test.txt", 2)
$text.Application.Quit

The number 2 corresponds to the Word VBA constant wdFormatText, which tells Word to save the file as text.

-S

Thanks !!! Works great !

Just wondering how I can jump lines ???

Thanks a lot

UPDATE: $text.Selection.TypeParagraph()

That's the one :whistle:

Just a question, where can I find all these parameters for applications ?

For example "TypeParagraph" ...

My goal is to create a folder in outlook in "Inbox" folder...

I have been having a very tough time....

Edited by Zoroxeus

Share this post


Link to post
Share on other sites

Thanks !!! Works great !

Just wondering how I can jump lines ???

Thanks a lot

UPDATE: $text.Selection.TypeParagraph()

That's the one :whistle:

Just a question, where can I find all these parameters for applications ?

For example "TypeParagraph" ...

My goal is to create a folder in outlook in "Inbox" folder...

I have been having a very tough time....

That's the big question. Where do I get a list of methods, properties, collections, etc.? Unfortunately, it's not easy to get that kind of information lump-sum. It takes a lot of research.

You can use the VBA editor and object browser to help you out, though, as well as the macro recorder. Create a macro that does what you want to do, then look at the VBA code for the macro in the VBA editor.

In Word, hit ALT+F11 to get into the VBA editor. Then hit F1 for VBA help. Then hit F2 for the object browser. Between these two things, you should be able to find some really good information.

VBA in Outlook is more complicated. VBA isn't as cleanly integrated; you have to access it via forms or through another Office application. I suggest a good Google search on Outlook VBA.

Here's a good resource on the subject:

http://www.outlookcode.com/d/vb.htm

-S


(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0