alexthecodepoet
asked on
cant add hyperlink to word doc
Hello,
I am trying to insert a hyperlink into a word document using this code:
Dim objWord
Sub Btn1_onclick()
call OpenDoc("C:\database\test. doc")
End Sub
Sub OpenDoc(strLocation)
Set objWord = CreateObject("Word.Applica tion")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("C: \database\ test.doc")
Set objSelection = objWord.Selection
objWord.Selection.TypeText ("This is the text ")
objWord.Selection.TypePara graph()
With objSelection.Find
.Text = "Bensley"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
objSelection.Find.Execute
ActiveDocument.Hyperlinks. Add Anchor:=Selection.Range, Address:= _
"http://www.website.com/index.aspx?definitionID=d091283la", _
SubAddress:="", ScreenTip:= _
"Screentip Text" _
, TextToDisplay:="TextToDisp layWord"
objDoc.SaveAs "c:\database\test2_no_hype rlinks4.do c"
I am using a website to do this.
The problem occurs on the ActiveDocument.Hyperlinks. Add line... it wont add a hyperlink. nothing happens.
Does anyone know how to fix this, or to insert a hyperlink?
Thanks,
I am trying to insert a hyperlink into a word document using this code:
Dim objWord
Sub Btn1_onclick()
call OpenDoc("C:\database\test.
End Sub
Sub OpenDoc(strLocation)
Set objWord = CreateObject("Word.Applica
objWord.Visible = True
Set objDoc = objWord.Documents.Open("C:
Set objSelection = objWord.Selection
objWord.Selection.TypeText
objWord.Selection.TypePara
With objSelection.Find
.Text = "Bensley"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
objSelection.Find.Execute
ActiveDocument.Hyperlinks.
"http://www.website.com/index.aspx?definitionID=d091283la", _
SubAddress:="", ScreenTip:= _
"Screentip Text" _
, TextToDisplay:="TextToDisp
objDoc.SaveAs "c:\database\test2_no_hype
I am using a website to do this.
The problem occurs on the ActiveDocument.Hyperlinks.
Does anyone know how to fix this, or to insert a hyperlink?
Thanks,
ASKER
Hm, i tried that, but still, nothing happens..
Try this
objWord.ActiveDocument.Hyp erlinks.Ad d Anchor:=objselection.Range , Address:= _
"http://www.website.com/index.aspx?definitionID=d091283la", _
SubAddress:="", ScreenTip:= _
"Screentip Text" _
, TextToDisplay:="TextToDisp layWord"
objWord.ActiveDocument.Hyp
"http://www.website.com/index.aspx?definitionID=d091283la", _
SubAddress:="", ScreenTip:= _
"Screentip Text" _
, TextToDisplay:="TextToDisp
ASKER
still nothing :(
well it works for me. Do you have any error?
---------- ---
objWord.ActiveDocument.Hyp erlinks.Ad d Anchor:=objselection.Range ,
change there
---------- ---
objWord.ActiveDocument.Hyp
change there
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
objWord.ActiveDocument.Hyp
"http://www.website.com/index.aspx?definitionID=d091283la", _
SubAddress:="", ScreenTip:= _
"Screentip Text" _
, TextToDisplay:="TextToDisp