Jump to content
Sign in to follow this  
Jury

_WordDocAddLink

Recommended Posts

Jury

Hi all,

I've been trying to get Mass Spammer's fine example of _WordDocAddLink to hyperlink all occurances of [2011] EWHC 2244 (COP) in the target document - this works fine when I know there are 2 occurances but is there some object variable I need to use in order to do this? I've looked at word macros and found : Selection.Find.Execute Replace:=wdReplaceAll

but Replace:=wdReplaceAll doesn't work or isn't recognised as a replacement for Execute in my script below - is it something to do with Range? There must be a way to specify all occurances.

#include <Word.au3>
#AutoIt3Wrapper_UseX64 = n
$cite = "[2011] EWHC 2244 (COP)"
;"C:\Users\Joe\Documents\AutoIt_code\getter\processing"
;"C:\Documents and Settings\joe.ury\My Documents\AutoIt_code\getter\processing\test.doc"
$oWordApp = _WordAttach ("C:\Users\Joe\Documents\AutoIt_code\getter\processing\test.rtf")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
;MsgBox(0, "Document Count", $oDoc)
$oSelect = $oDoc.Application.Selection
$oFind = $oSelect.Find
For $x = 1 to 2
With $oFind
.Text = $cite
.Forward = True
.Wrap = 1
.Execute
EndWith
_WordDocAddLink ($oDoc, $oSelect.Range, "[url="http://www..bongo.org/ew/cases/EWHC/COP/2011/2244.html"]http://www.bongo.org/ew/cases/EWHC/COP/2011/2244.html[/url]", "", "BAILII Link" & @CRLF, $cite)
;EndIf
$oLinks = _WordDocLinkGetCollection ($oDoc)
;If _WordDocFindReplace($oDoc, $cite) = 1 Then ExitLoop
Next
ConsoleWrite("Link Count " & @extended & @LF)

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  

×