Sign in to follow this  
Followers 0
autosc

office object

6 posts in this topic

I am fresh with autoit .

I discovered , how easy it is to learn autoit .

however i get stuck with this script which i found on the forum ...

I am working a lot with Microsofts winword .

what i am doing is simple ... add some text at the begining or end of the text .

to do that ,I must open manually thousand of files .

Instead , i thought it would be easier to open the document add the text an save it

with this script .... in loop ! but failed to do a single one .

here is the script i modified and not working ....

dont angry with me, if their is annoying part of my modification ...

it is my second day ... !

#include <IE.au3>

#include <GUIConstants.au3>

$word = ObjCreate("Word.Application")

$word.visible = False

$word.Documents.open(resume.doc)

$word.Selection.TypeText( "november 26 " )

$word.Selection.Font.Bold = True

$word.Selection.TypeText( "" )

$word.Selection.Font.Bold = False

$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )

$word.Activedocument.SaveAs( "resume.doc" )

$word.Application.Quit

Share this post


Link to post
Share on other sites



This worked for me. Probably just need to specify the full path to the file.

$word = ObjCreate("Word.Application")
$word.visible = False
$word.Documents.open(@ScriptDir & "\resume.doc")

$word.Selection.TypeText( "november 26 " )
$word.Selection.Font.Bold = True
$word.Selection.TypeText( "" )
$word.Selection.Font.Bold = False
$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )
$word.Activedocument.SaveAs(@ScriptDir & "\resume.doc" )
$word.Application.Quit

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

This worked for me. Probably just need to specify the full path to the file.

$word = ObjCreate("Word.Application")
$word.visible = False
$word.Documents.open(@ScriptDir & "\resume.doc")

$word.Selection.TypeText( "november 26 " )
$word.Selection.Font.Bold = True
$word.Selection.TypeText( "" )
$word.Selection.Font.Bold = False
$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )
$word.Activedocument.SaveAs(@ScriptDir & "\resume.doc" )
$word.Application.Quit

Big thanks ! Bluebear ! even it worked for me ... !

My next step is to save the documents in htm format to store as web documents .

This line : works

$word.Activedocument.SaveAs(@ScriptDir & "\resume.htm" )

but the htm file is not readable clearly by Webrowser ?

any ideas ??

Share this post


Link to post
Share on other sites

Big thanks ! Bluebear ! even it worked for me ... !

My next step is to save the documents in htm format to store as web documents .

This line : works

$word.Activedocument.SaveAs(@ScriptDir & "\resume.htm" )

but the htm file is not readable clearly by Webrowser ?

any ideas ??

Is there a way how to manipulate /embed winword object in GUI in order to

access the words file the meny system ?

and which accomplishes the task as above ...?

Share this post


Link to post
Share on other sites

My next step is to save the documents in htm format to store as web documents .

My suggestion to you is to go into the Visual Basic editor in Word and read the help file on the Word object model to find out what options are available for each method in Word. When I did this, I found that I could use an option to the SaveAs method to specify the format. The next trick was figuring out how to get AutoIt to use MS Word constants. I couldn't get it to work, so I wrote a macro in Word to display the value of the constant I wanted:

Public Sub Test()
    MsgBox ("wdFormatHTML = " & wdFormatHTML)
End Sub

Once I had this value (8), I modified the AutoIt code as follows:

Const $wdFormatHTML = 8

$word = ObjCreate("Word.Application")
$word.visible = False
$word.Documents.open(@ScriptDir & "\resume.doc")

$word.Selection.TypeText( "november 26 " )
$word.Selection.Font.Bold = True
$word.Selection.TypeText( "" )
$word.Selection.Font.Bold = False
$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )
$word.Activedocument.SaveAs(@ScriptDir & "\resume.doc" )
$word.Activedocument.SaveAs(@ScriptDir & "\resume.htm", $wdFormatHTML )
$word.Application.Quit

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Is there a way how to manipulate /embed winword object in GUI in order to

access the words file the meny system ?

and which accomplishes the task as above ...?

Use this:

$wdFormatHTML = 8
$word.Activedocument.SaveAs(@ScriptDir & "\resume.html",$wdFormatHTML )

EDIT: O.K. a few minutes too late ;-)

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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