AutoitMike Posted September 17, 2012 Posted September 17, 2012 In Win XP I am able to attach to a Word document using the window's handle. In Win 7, 64 bit, it fails to attach. @Error is encountered. Code: $Handle=WinGetHandle("[ACTIVE]") ;which is a Word document window $WordApp=_WordAttach($Handle,"HWND") If @error then MsgBox(0,"","An Error was encountered") EndIf I can , however, attach using text: $WordApp=_WordAttach("Text in the Document", "Text") However, I would like to know if there is a fix for this, work around, or a newer version of AutoIt Thanks
water Posted September 26, 2012 Posted September 26, 2012 I have been on vacation. Did you find a solution to this problem? 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
AutoitMike Posted October 3, 2012 Author Posted October 3, 2012 (edited) Yes, using title and text, but the handle mode is my preferred method. (this is in the first post) Edited October 3, 2012 by AutoitMike
ryadical Posted September 12, 2013 Posted September 12, 2013 I know this is an old topic but I think I tracked down this issue. I do not know how to "fix" it but i have a workaround. The function _WordAttach() calls the function __WordGetHWND() which ends up failing on my computer. I tracked it down to the line: If Not $oWordErrorHandler.number = 0 Then Return SetError($_WordStatus_ComError, 0, 0) If you commend out this line, it seems to "fix" the issue. $oWordErrorHandler.number seems to be a "random" 8 digit number. (im sure there is some logic behind what the number is, so it is probably not actually random) If the function is called more than once, (more than one word window open) it returns the same number but if you run a new instance of your application it is different. At this point debugging this is way over my head.
water Posted September 12, 2013 Posted September 12, 2013 Why do you need to use the window handle to attach to Word? Wouldn't the document title or filename be a better choice? The Word UDF of AutoIt 3.3.8.1 was completely rewritten for the next version. It is already implemented in the latest beta. It lifts the limitations but is incompatible with the current version. _Word_Attach then no longer supports HWND as parameter. 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
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