Sign in to follow this  
Followers 0
gigi1

error getting object of winword

6 posts in this topic

hi, i can't figure out how to solve this problem, i'm not experienced in Object-oriented coding :)

i'm trying to get the object of an existing word application.

the problem is that the script returns an error every time it tries to get the object of word after it is open. Example: i launch my script, then i launch winword.exe, the script start returning errors (it tries every second, returning the same error), then i minimize the window or focus on another one, and when i focus back on word it works as espected.

Here's the code giving problem

$oWord = ObjGet("", "Word.Application")
   If @error Then ;(the script outputs the error)

the word.au3 is included and i call _WordErrorHandlerRegister() before the ObjGet. This is the SciTE output:

--> COM Error Encountered in Client.au3

----> $WordComErrorScriptline = 140

----> $WordComErrorNumberHex = 800401E3

----> $WordComErrorNumber = -2147221021

----> $WordComErrorWinDescription = Operazione non disponibile.

----> $WordComErrorDescription =

----> $WordComErrorSource =

----> $WordComErrorHelpFile =

----> $WordComErrorHelpContext =

----> $WordComErrorLastDllError = 14007

(line 140 is the ObjGet() line - see above)

("Operazione non disponibile" is italian and means "Operation unavailable")

Obviously the script checks if the process winword.exe exists and if is active before trying to ObjGet()

Thanks in advance

Share this post


Link to post
Share on other sites



bump please

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I've seen you have the word.au3 included in your script. Why don't you use the functions word.au3 provides?

For details please check the AutoIt help file -> User Defined Funtions -> Word

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

is there a function returning the Object of an existing word application? i have just seen _WordCreate(), but it creates a new document, doesnt' it?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Unfortunately I'm not at my Windows PC so I can't check the available Word functions. But I know that the Excel UDF provides a way to attach to an existing/running Excel sheet.

Please check if the Word UDF provides a similar function or _WordCreate offers some way (a flag?) to attach to an existing Word instance.

Edit: _WordAttach should do the trick.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

yea it works...

i feel like an idiot :).

Thanks a lot!

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