Two thoughts:
-- Don't use ActiveDocument when you already have WordDoc as a document
object reference
-- Dim a range as Word.Range and Set it to the place you need the hyperlink
installed, and use that reference instead of "Selection".
Depending on what else is going on, "ActiveDocument" and "Selection" can
give you many headaches!
Ed
> Hi Tony,
>
[quoted text clipped - 34 lines]
>> > ScreenTip:="", TextToDisplay:="Activity"
>> > End With
Hi Ariel,
I tried your code both from Word and Excel. I was getting slightly
different error. I am not sure how Word's selection method canwork when
automating the application from outside Word so have substituted a
Range variable instead.
The code below may help you. It works from Excel.
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = New Word.Application
'This allows you to see the application
WordApp.Visible = True
'This creates a document in the new Application process
Set WordDoc = WordApp.Documents.Add
With WordDoc 'WordApp.ActiveDocument
'playing around here to demonstrate moving around the doc
WordDoc.Range.InsertAfter "aaaaaaa" & vbCr & "bbbbbbbbbbbbb" &
vbCr
Dim rng As Range
Set rng = .Range
rng.Collapse wdCollapseStart
rng.MoveStartUntil "b"
.Hyperlinks.Add Anchor:=rng, _
Address:="http://www.ohsu.edu/hms/survey/activity/brief", _
SubAddress:="", _
ScreenTip:="tip", _
TextToDisplay:="Activity"
End With
Once you have the above working you should be able to substitute the
range with say a bookmark range in order to insert your link where you
want it.
Hope this helps.
Cheers
TonyS.
> Hi Tony,
>
[quoted text clipped - 32 lines]
> > > ScreenTip:="", TextToDisplay:="Activity"
> > > End With
Ariel - 28 Sep 2006 16:08 GMT
Hi Tony,
I tried your code and I get a "type mismatch" error at Set rng = .Range
thanks
Ariel
> Hi Ariel,
>
[quoted text clipped - 77 lines]
> > > > ScreenTip:="", TextToDisplay:="Activity"
> > > > End With
Helmut Weber - 28 Sep 2006 16:17 GMT
Hi Ariel,
try:
Dim rng As word.Range

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Ariel - 28 Sep 2006 17:10 GMT
Works like a charm. Thank you all for your input. It is great having such
support!
> Hi Ariel,
>
> try:
>
> Dim rng As word.Range
Ariel - 06 Oct 2006 01:50 GMT
Hi Tony,
I have been trying unsuccessfully to get the cursor to move past the
inserted hyperlink so that I can add in another one (or a series of them if
necessary) and then continue on with a new paragraph.
Do you have a suggestion of how I can do this (remember that this code is
being written in Excel VBA).
Thanks for your help!
Ariel
> Hi Ariel,
>
[quoted text clipped - 77 lines]
> > > > ScreenTip:="", TextToDisplay:="Activity"
> > > > End With