Hi anyone, I'm looking for a straightforward way if setting
values in bookmarks without them disappearing.
(Users of my work will then not be able to utilize the bookmarks that I've
populated)

This worked with DDE, but I want to use OLE.
This is how I do it.

ActiveDocument.Bookmarks("strBookMarkName").Range = strBookmarkValue

This causes the bookmark to disappear in faluor of the value but I want them
both.

Re: Disappearing bookmarks by Mark

Mark
Wed Sep 17 02:17:20 CDT 2003

Erik,

If you set up the bookmark to enclose a space: []
rather than to mark a spot: I
and use .Range.InsertAfter instead of .Range.Text
(using just .Range as in your code below isn't
strictly kosher), your code won't obliterate it.

--
Mark Tangard <Mark@Tangard.com>, Microsoft Word MVP
Please reply only to the newsgroup, not by private mail.
Note well: MVPs do not work for Microsoft.
"Life is nothing if you're not obsessed." --John Waters





Erik Lundberg wrote:
>
> Hi anyone, I'm looking for a straightforward way if setting
> values in bookmarks without them disappearing.
> (Users of my work will then not be able to utilize the bookmarks that I've
> populated)
>
> This worked with DDE, but I want to use OLE.
> This is how I do it.
>
> ActiveDocument.Bookmarks("strBookMarkName").Range = strBookmarkValue
>
> This causes the bookmark to disappear in faluor of the value but I want them
> both.

Re: Disappearing bookmarks by mksmith

mksmith
Wed Sep 17 02:24:30 CDT 2003

You're half way there. Before you overwrite the Range of the bookmark
save the range in a Range variable.

Then the next step is to change the value of the Range to the new text and
then add the bookmark to the Range.

It should work a little like this:


Sub UpdateBookmark (sBookmark as string, sValue as string)

Dim oRange as Range

If Documents.Count > 0 then
If ActiveDocument.Bookmarks.Exist (sBookmark) then
Set oRange = ActiveDocument.Bookmarks(sBookmark).Range
oRange.Text = sValue
ActiveDocuments.Bookmarks.Add sBookmark, oRange
End if
End if

End sub


Since I am just doing this from the top of my head it may need tweaking,
but you ought to get the idea.

Regards
Malc
www.dragondrop.com