Sign in to follow this  
Followers 0
mattw112

Getting links from word doc

6 posts in this topic

I'm trying to run a test to get the links from a word document.

I've found several examples on how to create a new document, add a link then report on it, ... but haven't seen doing it with an existing document.

So trying this code:

#include <Word.au3>
$oWordApp = _WordCreate("D:\temp\Content.doc")
$oDocs = _WordDocGetCollection ($oWordApp, 0)

$oLinks = _WordDocLinkGetCollection ($oDocs)
MsgBox(0, "test", $oLinks & @CRLF & @extended & @CRLF & @error)     ; Returns 0, 1, 3

$sMsg = "Link Count = " & @extended & @CRLF
MsgBox(0, "test", $sMsg)                                            ; Shows: "Link Count = 0"

For $oLink In $oLinks
    $sMsg &= "TextToDisplay: " & $oLink.TextToDisplay & "  Address: " & $oLink.Address & @CRLF
Next
;>>> Get Error Here: "Variable must be of type object"
MsgBox(0, "test", "4")

MsgBox(64, "Links", $sMsg)

The document for now is just a word document I created (.doc) and added a single link. Text = "Hi" and link="www.yahoo.com"

But if you look at the code above you can see the error I'm seeing and the other msgbox'es I've put in.

Can someone point out what I'm doing wrong?

Thanks,

Terry

Share this post


Link to post
Share on other sites



I got link count = 0 but I also got the link text and address so I dunno what's up!

Share this post


Link to post
Share on other sites

I got link count = 0 but I also got the link text and address so I dunno what's up!

I have Office 2010 on my system. My system is Windows 7 X64 would any of that matter?

Terry

Share this post


Link to post
Share on other sites

I had problems with Windows 7 64 bit and Office 2010 32 bit when the AutoIt script was run for 64 bit. I changed AutoIt to run for 32 bit and everything was fine again.


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

I had problems with Windows 7 64 bit and Office 2010 32 bit when the AutoIt script was run for 64 bit. I changed AutoIt to run for 32 bit and everything was fine again.

That was it!!

But it is still weird that it says 0 links but then still shows me the text and address?

Terry

Share this post


Link to post
Share on other sites

That was it!!

But it is still weird that it says 0 links but then still shows me the text and address?

Terry

64-bit applications and 32-bit COM objects do not play nicely together.

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