gadzail Posted November 22, 2006 Posted November 22, 2006 Everyone knows why if I use the object $objWord = ObjCreate("Word.Application")with RTF files everything is OK BUT if I use the same objectwith 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).RangeDOESN'T FUNCTIONbut$dir=@ScriptDir$file="Barcode.rtf"$objDoc = $objWord.Documents.Open($dir&"\"&$file)$objDoc.Tables(1).RangeWORKS FINE.
lod3n Posted November 22, 2006 Posted November 22, 2006 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 big_daddy Posted November 23, 2006 Moderators Posted November 23, 2006 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.
Valuater Posted November 23, 2006 Posted November 23, 2006 take heed to... not... just worth looking at!!! 8)
gadzail Posted November 23, 2006 Author Posted November 23, 2006 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.
gadzail Posted November 23, 2006 Author Posted November 23, 2006 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now