Sign in to follow this  
Followers 0
AutoitMike

_WordAttach Cannot attach using handle in Win7

5 posts in this topic

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

Share this post


Link to post
Share on other sites



I have been on vacation. Did you find a solution to this problem?


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

#3 ·  Posted (edited)

Yes, using title and text, but the handle mode is my preferred method. (this is in the first post)

Edited by AutoitMike

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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 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

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