rename bookmark

P

Perry

Delete and Recreate on the same range object and make sure the changes you
made, apply to the correct template/

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
J

JensB

From a vb.net app I insertfromfile some text blocks including a bookmark.

If I insert the same text block more than once, one of the bookmarks
disappear.
I want to be in control with bookmarks, as I have to collect values from
them.
My question is:
Is it possible to rename a bookmark programmatically ?
(the bookmarks(i)name property is read only)
JensB
 
J

JensB

Perry
thx for fast response
I am using word 11.0 lib, and is not an expert programmer.
I am not sure i understand how to recreate a range.
I use this line to find the bookmark
..GoTo(What:=wdGoToBookmark, Name:="Machine no1")
Could you please give me a line or two to how to change the bookmark name to
"Machine no1-a")
JensB
 
D

Doug Robbins - Word MVP

Don't change the name, add a new bookmark to the document with the same
range as the existing bookmark

Dim i As Long
With ActiveDocument
.Bookmarks.Add Name:="NewBookmark" & i,
Range:=.Bookmarks("ExistingBookmark").Range
'Increment i
End With

The "ExistingBookmark" will be deleted when you insert another textblock

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

JensB

Doug
this made my day.
I am also using formfields which have a different behaviour, I assume there
is similar way to do same sekvens,
is there any chance you could tell me the same functionality for a
formfield.

JensB
 
J

JensB

Doug
Indeed it helped a lot.
from the link, I did some test, and found this code to work well with
formfields,
as long as the formfield already has a name.
..GoTo(What:=wdGoToBookmark, Name:=ExistingBookmark)
..FormFields(ExistingBookmark).Name = ExistingBookmark & i
'Increment i
Thx again
JensB
 
J

JensB

Just for the record.
I found out, that it is also posible to make a new formfield and name it in
the same process.
..FormFields.Add(Range:=.Range, Type:=wdFieldFormTextInput).Name =
NewBookmarkName
JensB
 

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