i want to add bookmarks to a document that use the value of a string as the
bookmark name. An extract of the code is below.
strBookmarkID = DateID
mydoc.Bookmarks.Add Name:="strBookmarkID", Range:=Selection.Range
where DateID is the output of a function to create a unique string value for
the bookmark.
All i get is a bookmark named strBookmarkID and not the value of
strBookmarkID.
any ideas?
Thanks
Lene Fredborg - 01 Nov 2007 00:13 GMT
Remove the quotes around strBookmarkID:
mydoc.Bookmarks.Add Name:=strBookmarkID, Range:=Selection.Range

Signature
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
> i want to add bookmarks to a document that use the value of a string as the
> bookmark name. An extract of the code is below.
[quoted text clipped - 12 lines]
>
> Thanks
James N. - 01 Nov 2007 00:28 GMT
Thanks Lene,
on looking at the DateID function i remembered that the format was T111-T222
and the - character is not allowed in bookmarks.
regards,
James
> Remove the quotes around strBookmarkID:
>
[quoted text clipped - 16 lines]
> >
> > Thanks
Russ - 05 Nov 2007 05:33 GMT
James,
An underscore character is legal for bookmark names.
Try:
mydoc.Bookmarks.Add Name:=Replace(strBookmarkID,"-","_"), _
Range:=Selection.Range
To give i.e., T111_T222
> Thanks Lene,
>
[quoted text clipped - 25 lines]
>>>
>>> Thanks

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Steve Yandl - 01 Nov 2007 00:14 GMT
In the line where you add the bookmark, get rid of the quotes around your
variable.
mydoc.Bookmarks.Add Name:="strBookmarkID", Range:=Selection.Range
should be
mydoc.Bookmarks.Add Name:=strBookmarkID, Range:=Selection.Range
Steve
>i want to add bookmarks to a document that use the value of a string as the
> bookmark name. An extract of the code is below.
[quoted text clipped - 13 lines]
>
> Thanks