Jump to content

_WordAttach Cannot attach using handle in Win7


AutoitMike
 Share

Recommended Posts

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

Link to comment
Share on other sites

  • 2 weeks later...

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

  • 11 months later...

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. 

Link to comment
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 2022-02-19 - Version 1.6.1.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 (NEW 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...