mattw112 Posted April 5, 2011 Share Posted April 5, 2011 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 Link to comment Share on other sites More sharing options...
MrMitchell Posted April 5, 2011 Share Posted April 5, 2011 I got link count = 0 but I also got the link text and address so I dunno what's up! Link to comment Share on other sites More sharing options...
mattw112 Posted April 5, 2011 Author Share Posted April 5, 2011 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 Link to comment Share on other sites More sharing options...
water Posted April 5, 2011 Share Posted April 5, 2011 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mattw112 Posted April 6, 2011 Author Share Posted April 6, 2011 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 Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 6, 2011 Moderators Share Posted April 6, 2011 That was it!!But it is still weird that it says 0 links but then still shows me the text and address?Terry64-bit applications and 32-bit COM objects do not play nicely together. Link to comment Share on other sites More sharing options...
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