gigi1 Posted March 18, 2011 Share Posted March 18, 2011 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 Link to comment Share on other sites More sharing options...
gigi1 Posted March 19, 2011 Author Share Posted March 19, 2011 bump please Link to comment Share on other sites More sharing options...
water Posted March 19, 2011 Share Posted March 19, 2011 (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 March 19, 2011 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gigi1 Posted March 19, 2011 Author Share Posted March 19, 2011 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? Link to comment Share on other sites More sharing options...
water Posted March 19, 2011 Share Posted March 19, 2011 (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 March 19, 2011 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gigi1 Posted March 19, 2011 Author Share Posted March 19, 2011 yea it works... i feel like an idiot . Thanks a lot! Link to comment Share on other sites More sharing options...
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