Jump to content

Recommended Posts

Posted

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.

Posted

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]

  • Moderators
Posted

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.

Posted

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.

Posted

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.

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
×
×
  • Create New...