Jump to content

Recommended Posts

Posted

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
Posted

What's the value of @error after you called _WordDocAddLink?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

 

Posted

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)

Posted

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

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", "", "") 
 
Posted

:)

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 2024-07-28 - Version 1.6.3.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 (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

 

Posted

:)

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.

Posted

Great to hear that Word 2013 seems to be "compatible" with older versions of Word.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

 

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
×
×
  • Create New...