Bookmark.Start Property

  • Thread starter Bookmark.Start Property
  • Start date
B

Bookmark.Start Property

I have a file " *.docx". That document has 2 bookmarks: BM1 and BM2.
Star of BM1 is 1, end of BM1 is 10;
Star of BM2 is 5,end of Bm2 is 20;
// Change star of BM2 to 10;
BM2.Star = 10;

An occurrent, BM2.star is still 5; This command has no exception.

Word Developer Reference
Bookmark.Start Property : Returns or sets the starting character position of
a bookmark. Read/write Long.
http://msdn.microsoft.com/en-us/library/bb179673.aspx
 
L

Lene Fredborg

I can change the range of bookmarks by setting the Start and End properties
without problems (have used that method often). The following macro adds two
bookmarks and changes the ranges of the bookmarks afterwards:

Sub TestChangeBookmarkRange()
Dim BM1 As Bookmark
Dim BM2 As Bookmark

'Add bookmarks
Set BM1 = ActiveDocument.Bookmarks.Add(Name:="BM1",
Range:=ActiveDocument.Range(1, 10))
Set BM2 = ActiveDocument.Bookmarks.Add(Name:="BM2",
Range:=ActiveDocument.Range(5, 20))

'Change bookmark range
BM1.End = 15
BM2.Start = 10

Set BM1 = Nothing
Set BM2 = Nothing

End Sub

What happens if you test that macro? In your post, you have consistenly
written “Star†instead of “Start†– I suppose that error is not in your macro.


--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
S

Stefan Blom

Hmm, this is interesting. If you create the bookmarks manually (via the user
interface), which is what I did in my quick test, can you still redefine
their ranges using code?
 
L

Lene Fredborg

Stefan,

Yes, I can. It works the same for me regardless of how I create the bookmarks.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
L

Lene Fredborg

Can you make it work now?

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
S

Stefan Blom

Well, I haven't had the time to make any additional testing but, as I wrote,
your example did work fine.
 
Top