zdgastineau Posted November 4, 2013 Share Posted November 4, 2013 I have been unsuccessful in adding more than one link to a collection. Can someone tell me what I'm doing wrong: Local $oWordApp = _WordCreate("") Local $oDoc = _WordDocOpen($oWordApp, $BuildDoc) _WordDocAddLink($oDoc, "", $BuildFolder & "IIS", "", "") _WordDocAddLink($oDoc, "", $BuildFolder & "sql", "", "") _WordDocAddLink($oDoc, "", $BuildFolder & "ssis", "", "") $oLinks = _WordDocLinkGetCollection ($oDoc) $sMsg = "Link Count = " & @extended & @CRLF msgbox(0,"zdg",$sMsg) For $oLink In $oLinks $sMsg &= "TextToDisplay: " & $oLink.TextToDisplay & " Address: " & $oLink.Address & @CRLF ;msgbox(0,"zdg",$sMsg) Next Result is the a count of 1 and the first link that was added. Thanks Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 What's the value of @error after you called _WordDocAddLink? 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...
zdgastineau Posted November 5, 2013 Author Share Posted November 5, 2013 What's the value of @error after you called _WordDocAddLink? It was 0 each time. _WordDocAddLink($oDoc, "", $BuildFolder & "IIS", "", "") msgbox(0,"error:",@error) _WordDocAddLink($oDoc, "", $BuildFolder & "sql", "", "") msgbox(0,"error:",@error) _WordDocAddLink($oDoc, "", $BuildFolder & "ssis", "", "") msgbox(0,"error:",@error) Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 I see the last link added ("ssis"). As a default _WordDocAddLink assigns the link to the whole document if parameter 2 is empty. Hence link 3 overwrites links 1 and 2. You need to pass a range object as parameter 2 where you want to set the link. 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...
zdgastineau Posted November 5, 2013 Author Share Posted November 5, 2013 I see the last link added ("ssis"). As a default _WordDocAddLink assigns the link to the whole document if parameter 2 is empty. Hence link 3 overwrites links 1 and 2. You need to pass a range object as parameter 2 where you want to set the link. Ah Range was the missing link. Thank you very much for your help... here is my final resolution: The following worked as intended. Local $oWordApp = _WordCreate("") Local $oDoc = _WordDocOpen($oWordApp, $BuildDoc) Local $oDoc = _WordDocGetCollection($oWordApp, 0) Local $oRange = $oDoc.Range _WordDocFindReplace($oDoc, "~WebPath~", $BuildFolder & "IIS",1, $oRange) _WordDocAddLink($oDoc, $oRange, $BuildFolder & "IIS", "", "") _WordDocFindReplace($oDoc, "~DBPath~", $BuildFolder & "SQL",1, $oRange) _WordDocAddLink($oDoc, $oRange, $BuildFolder & "SQL", "", "") _WordDocFindReplace($oDoc, "~SSISPath~", $BuildFolder & "SSIS",1, $oRange) _WordDocAddLink($oDoc, $oRange, $BuildFolder & "SSIS", "", "") Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 The next version of AutoIt comes with my rewrite of the Word UDF. Is much more flexible and supports the latest versions of Word. It is already included in the latest beta version. It is NOT compatible with the current Word UDF. 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...
zdgastineau Posted November 5, 2013 Author Share Posted November 5, 2013 The next version of AutoIt comes with my rewrite of the Word UDF. Is much more flexible and supports the latest versions of Word. It is already included in the latest beta version. It is NOT compatible with the current Word UDF. Very good. Thanks for all you do. These are very helpful. FYI I'm using Word 2013 and my solution above worked. I think I'm using version v3.3.8.1 of AutoIT. Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 Great to hear that Word 2013 seems to be "compatible" with older versions of Word. 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...
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