Excel create bookmark

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This code is trying to create a bookmark in Word from Excel,
The problem is it creates a bookmark that is the whole document rather than
just the text <Insert link here>
Any ideas how to fix this?
Thanks,

With WordDoc.Content.Find
.text = "<Insert link here>"
If .Execute Then
WordDoc.Bookmarks.Add Name:="bmRlsPlan", Range:=WordDoc.Content
End If
End With
 
You might get more help in the Word programming newsgroup, but the
following may work for you:

'===============
Dim rngFind As Range
Set rngFind = WordDoc.Content

With rngFind.Find
.Text = "<Insert link here>"
If .Execute Then
rngFind.Bookmarks.Add _
Name:="bmRlsPlan", Range:=rngFind
End If
End With
'=========================
 
This line gives an error, Compile error: Argument not optional
Any way around this?

With rngFind.Find


thanks,
 
Change the first line to:

Dim rngFind As Word.Range

and it should work correctly.
 

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

Back
Top