WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Word

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create Hyperlinks in Word


Question:

I am trying to write a number of hyperlinks into the same document. I have a script that runs on my file server and flags any files that meet certian criteria and then I write the paths to those files into a logfile - I would like all the paths in the logfile to be hyperlinked.

Answer:


docfile = "c:\temp\temp.doc"
objWord = objectopen("Word.Application")
objWord.visible = @true
objDocs = objWord.Documents
objDocs.Open(docfile)
objActDoc = objWord.ActiveDocument
objSelection = objWord.Selection
objHyperlinks = objActDoc.Hyperlinks

objRange = objSelection.Range
objHyperlinks.Add(:: Anchor=objRange, Address="C:\Temp\text1.txt", SubAddress="", ScreenTip="", TextToDisplay="Link 1")
objSelection.TypeParagraph

objRange = objSelection.Range
objHyperlinks.Add(:: Anchor=objRange, Address="C:\Temp\text2.txt", SubAddress="", ScreenTip="", TextToDisplay="Link 2")
objSelection.TypeParagraph

objRange = objSelection.Range
objHyperlinks.Add(:: Anchor=objRange, Address="C:\Temp\text3.txt", SubAddress="", ScreenTip="", TextToDisplay="Link 3")
objSelection.TypeParagraph

Pause("","Look at hyperlink the doc file")

ObjectClose(objHyperlinks)
ObjectClose(objRange)
ObjectClose(objSelection)
ObjectClose(objActDoc)
ObjectClose(objDocs)
ObjectClose(objWord)

Article ID:   W16143
File Created: 2004:03:30:15:42:58
Last Updated: 2004:03:30:15:42:58