gigi1 0 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 Share this post Link to post Share on other sites
water 2,387 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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
gigi1 0 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? Share this post Link to post Share on other sites
water 2,387 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 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
gigi1 0 Posted March 19, 2011 yea it works... i feel like an idiot . Thanks a lot! Share this post Link to post Share on other sites