Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Add a bookmark that uses a string as the bookmark name?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James N. - 31 Oct 2007 23:49 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.