create hyperlink assigned to word bookmark

M

MC

Hi,
I'm having trouble creating a hyperlink to assign to a bookmark in a
word doco. Below is the code I'm using. This is giving me a type
mismatch. The bookmark is called "hyper". I've tried various other
ways with no luck.


doc.Hyperlinks.Add Address="http://www.msn.com/", Anchor="This way",
SubAddress=doc.Bookmarks("hyper")

Any help much appreciated
 
M

Martin Seelhofer

Hi MC
doc.Hyperlinks.Add Address="http://www.msn.com/", Anchor="This way",
SubAddress=doc.Bookmarks("hyper")

First of all, you'll have to use := for named parameters (may be a typo in
your posting, though). Additionally, if you want to assign the Text "This
way"
to a bookmark called "hyper", the first step would be to write the text into
the document and create a bookmark out of it (--> shows as [This way] in
the document). Afterwards, you can assign a hyperlink to it using the
following code:

doc.Hyperlinks.Add Address:="http://www.msn.com/",
Anchor:=doc.Bookmarks("hyper").Range
Or shorter without named parameters:
doc.Hyperlinks.Add doc.Bookmarks("hyper").Range, "http://www.msn.com/"


Cheers,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top