Results 1 to 9 of 9
  1. #1
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Change the range of a bookmark (Word 2000 SR1a)

    I suspect that I am doing something very stupid, but I can't for the life of me see what it is.

    I have a bookmark that I need to move, when I execute code like.
    <pre>bmkTemp.Range.End = rngTemp.End
    </pre>

    (Where bmkTemp is my bookmark and rntTemp is a range showing where it should be)
    It silently does nothing. No error messages, no changes in the Watches window, no change in where the bookmark points.

    I have just run this in the de######. I can see that the two ranges have the same start point and different end points in the Watches window. I execute the code and it makes not a blind bit of difference!

    Is there something special about the range associated with a bookmark?

    Also, whilst we are asking, why does a bookmark have .Start and .End properties which appear to be identical to the .Range.Start and .Range.End properties?

    StuartR

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    You were very close:

    bmkTemp.End = rngTemp.End

    will work, at least in Word 97.

    According to Word 97 VBA help, the Range property of a bookmark is read-only, while the Start and End properties are read-write.

    I don't know why trying to assign a value to bmkTemp.Range.End doesn't cause an error - if the property is read-only it would seem logical. But as you noted, Word silently ignores the instruction.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    Thank you - that fixed it. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    I can see nothing in the help file that says that Range.End of a bookmark is read-only. Neither is there any explanation of why a bookmark has an .End property.

    StuartR

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    Online help mentions that the Range property of a bookmark is read-only. I just assume that this is inherited by its properties like Range.End.

    A quick search in Microsoft KB yielded no relevant information about this subject - but then, you never know, it might be buried somewhere in there.

    Did you really expect Microsoft to explain why they decided to include both a Range.End and End property?

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    > Online help mentions that the Range property of a bookmark is read-only
    I can't see this in Word 2000 SR1a

    StuartR

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    I could include a screenshot, but that wouldn't be very useful since my help file is in Dutch.

    If you look up the Bookmark object in the Object Browser, and then select the Range property, what does the description say? In Word 97, it says (in Dutch):

    Property Range As Range
    read-only
    Member of Word.Bookmark

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    You are right, I was looking in the help file, rather than the object browser.

    Thank you. <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

    StuartR

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    A bookmark and a range are entirely different critters.
    Thje starting/ending points of a range can be manipulated any which way but loose, but that has no effect on any bookmarks within the range.

    If you want to change the range to which a bookmark applies, you need to (re)apply the bookmark to that range.

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Change the range of a bookmark (Word 2000 SR1a)

    Howard,

    I realised that I needed "to (re)apply the bookmark to that range" but there didn't seem to be a sensible method for doing this! I even tried <font color=blue>set bmkTemp.Range = rngTemp.Duplicate</font color=blue> but that didn't work either. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    Now that I know how it is just a matter of manipulating the .Start and .End of the bookmark, rather than of its .Range, I am happy to get on with my code...

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •