Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Bookmarks in tables (Word VBA)

    Hi folks - is there something special one needs to know to be able to code for adding a bookmark to a document? I need to be able to do so and all I did was record the creation of the bookmark and try to play it back - but everytime it says it doesn't support this object - "object doesn't support this property or method". The entire macro just looks like this:

    <pre>Sub RecBlock()
    Selection.TypeParagraph
    Selection.MoveUp Unit:=wdLine, Count:=1
    With ActiveDocument.Bookmarks
    .Add Range:=Selection.Range, Name:="RECIPIENT_NAME"
    .DefaultSorting = wdSortByName
    .ShowHidden = False
    End With
    Selection.MoveDown Unit:=wdLine, Count:=1
    With ActiveDocument.Bookmarks
    .Add Range:=Selection.Range, Name:="RECIPIENT_ADDRESS"
    .DefaultSorting = wdSortByName
    .ShowHidden = False
    End With
    End Sub</pre>


    Exactly as recorded, but it just won't play!

    Help! <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    Beryl M


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

    Re: Bookmarks in tables (Word VBA)

    Hi Beryl,

    Your macro runs OK when I try it in Word 2003, whether the insertion point is inside a table or not. Where exactly does the error occur?

    BTW, the macro can be simplified to

    Sub RecBlock()
    Selection.TypeParagraph
    Selection.MoveUp
    ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="RECIPIENT_NAME"
    Selection.MoveDown
    ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="RECIPIENT_ADDRESS"
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Bookmarks in tables (Word VBA)

    Hi Hans, thanks for this, and yes, I know about the simplification - I had done that myself, but I undid it when the macro kept crashing in an effort to find out why! The first two lines, to type a return and move back up to the line thus created work, then i get the error message, but it wouldn't let me error check it!

    However, I have now tracked down the problem - a couple of lines of rogue code had crept in and were screwing the whole thing up!

    Sigh!

    Thanks anyway and sorry for wasting your time!!
    Beryl M


Posting Permissions

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