AWestEng
asked on
VBScript: Add hyperlink in table cell, Ms Word 2007
Hi how do I add a hyperlink in a table cell? (MS Word 2007)
I like the www.test.com to become a hyperlink.
I like the www.test.com to become a hyperlink.
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range
Set objRange = objDoc.Range
objRange.Collapse wdCollapseEnd
Set objTable = objDoc.Tables.Add(objRange, 2, 2)
objTable.Borders.Enable = true
With objTable.Cell(2, 2).Range
.Font.Name = "Verdana"
.Font.Size = 8
.Font.Bold = false
.Text = _
"Address for visitors:" & Chr(11) & _
"xxxxxxxxxx" & Chr(11) & _
"yyyyyyyyyy" & Chr(11) & _
"<a href='Web:www.test.com'>test.com/a>"
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
found it
Set objCell = objTable.Cell(2, 2)
Set objCellRange = objCell.Range
objCell.Select
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = 8
objSelection.Font.Bold = false
objSelection.TypeText _
"Xxxxxx:" & Chr(11) & _
"yyyyyy" & Chr(11) & _
"Web: "
objSelection.InsertAfter Text = "yyyyyy"
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = 8
objSelection.Font.Bold = true
Set objLink = objSelection.Hyperlinks.Ad d(objSelec tion.Range , "http://www.test.com", , , "www.test.com")
Set objCell = objTable.Cell(2, 2)
Set objCellRange = objCell.Range
objCell.Select
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = 8
objSelection.Font.Bold = false
objSelection.TypeText _
"Xxxxxx:" & Chr(11) & _
"yyyyyy" & Chr(11) & _
"Web: "
objSelection.InsertAfter Text = "yyyyyy"
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = 8
objSelection.Font.Bold = true
Set objLink = objSelection.Hyperlinks.Ad
ASKER
Xxxxxx
yyyyyy
www.test.com
now it look like this
Xxxxxx
yyyyyy
www.test.com