Sign in to follow this  
Followers 0
gadzail

problem: word.application with doc and rtf

6 posts in this topic

Everyone knows why if I use the object

$objWord = ObjCreate("Word.Application")

with RTF files everything is OK BUT if I use the same object

with DOC files some method or properties give me errors

"The requested action with this object has failed."

For example:

$dir=@ScriptDir

$file="Barcode.doc"

$objDoc = $objWord.Documents.Open($dir&"\"&$file)

$objDoc.Tables(1).Range

DOESN'T FUNCTION

but

$dir=@ScriptDir

$file="Barcode.rtf"

$objDoc = $objWord.Documents.Open($dir&"\"&$file)

$objDoc.Tables(1).Range

WORKS FINE.

Share this post


Link to post
Share on other sites



Dunno, this works for me:

$objWord = ObjCreate("Word.Application")
$objWord.visible = true
$dir=@ScriptDir
$file="Barcode.doc"
$objDoc = $objWord.Documents.Open($dir&"\"&$file)
;~ $objDoc.Tables(1).Range
sleep(1000)
$objWord.Quit (0, 0, 0)

Is it possible you have a previous instance of Word active but hidden? Try killing all winword.exe processes before running your script.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

My Word Automation Library may be worth taking a look at. It provides robust error checking to help troubleshoot problem like this. See me signature for the link.

Share this post


Link to post
Share on other sites

take heed to... not... just worth looking at!!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Dunno, this works for me:

$objWord = ObjCreate("Word.Application")
$objWord.visible = true
$dir=@ScriptDir
$file="Barcode.doc"
$objDoc = $objWord.Documents.Open($dir&"\"&$file)
;~ $objDoc.Tables(1).Range
sleep(1000)
$objWord.Quit (0, 0, 0)

Is it possible you have a previous instance of Word active but hidden? Try killing all winword.exe processes before running your script.

The problem is in the line with semicolon comment:

$objDoc.Tables(1).Range

Some properties work but others like $objDoc.Tables.*,

$objDoc.Words.*, etc. (for example $objDoc.Tables.count) don't work.

NOTE: I used the VBAWRD9.CHM in the office DOC.

PS: Sorry for my bad english, if you don't understand I will try to explain me better.

Share this post


Link to post
Share on other sites

My Word Automation Library may be worth taking a look at. It provides robust error checking to help troubleshoot problem like this. See me signature for the link.

Thanks, I'll try.

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