ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a hyperlink in Word from Excel (https://www.excelbanter.com/excel-programming/373790-creating-hyperlink-word-excel.html)

Ariel

Creating a hyperlink in Word from Excel
 
I am creating a word document using Excel and I need to add a hyperlink at a
given position in the text. For some reason the following code does not work.
WordApp has already been dim'ed.


With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With

Dave Peterson

Creating a hyperlink in Word from Excel
 
About the only thing I do with MSWord is record macros and try to tweak them.

But Selection.Range doesn't look like it belongs to the MSWord application.

I'd try:

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With



Ariel wrote:

I am creating a word document using Excel and I need to add a hyperlink at a
given position in the text. For some reason the following code does not work.
WordApp has already been dim'ed.

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With


--

Dave Peterson

Ariel

Creating a hyperlink in Word from Excel
 
Without specifically defining the location where this should be inserted,
everything else in the document is deleted.

"Dave Peterson" wrote:

About the only thing I do with MSWord is record macros and try to tweak them.

But Selection.Range doesn't look like it belongs to the MSWord application.

I'd try:

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With



Ariel wrote:

I am creating a word document using Excel and I need to add a hyperlink at a
given position in the text. For some reason the following code does not work.
WordApp has already been dim'ed.

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With


--

Dave Peterson


Dave Peterson

Creating a hyperlink in Word from Excel
 
Maybe it's time to ask in an MSWord newsgroup.



Ariel wrote:

Without specifically defining the location where this should be inserted,
everything else in the document is deleted.

"Dave Peterson" wrote:

About the only thing I do with MSWord is record macros and try to tweak them.

But Selection.Range doesn't look like it belongs to the MSWord application.

I'd try:

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With



Ariel wrote:

I am creating a word document using Excel and I need to add a hyperlink at a
given position in the text. For some reason the following code does not work.
WordApp has already been dim'ed.

With WordApp.ActiveDocument
.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.asdfasdfasfd.com", SubAddress:="", _
ScreenTip:="", TextToDisplay:="Activity"
End With


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com