Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    inserting and enclosing bookmark in vb (MSO 2003)

    Hi All,

    Rebrand time again. I have a macro that is updating a disclaimer in the footer of a letter. After inserting the disclaimer, I want to select the text that has just been entered and insert an enclosing bookmark, however, all I get is a placeholder bookmark:

    Code:
    Selection.TypeText Text:="***, a limited liability partnership registered in England & Wales " & _
            "(registered number: ***) authorised and regulated by the Solicitors Regulation Authority and the " & _
            "appropriate regulatory body in the other jurisdictions in which it operates."
        Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        With ActiveDocument.Bookmarks
            .Add Range:=Selection.Range, Name:="disclaimer"
            .DefaultSorting = wdSortByName
            .ShowHidden = False
        End With
    What am I missing here? My brain has packed up and left, been working my tail off for thirteen hours and just want to get finished, so any help would be gratefully received.

    Thanks!

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You could try to avoid the selection object
    Code:
      Dim aRng As Range
      Set aRng = Selection.Range
      aRng.Text = "***, a limited liability partnership registered in England & Wales " & _
        "(registered number: ***) authorised and regulated by the Solicitors Regulation Authority and the " & _
        "appropriate regulatory body in the other jurisdictions in which it operates."
      With ActiveDocument.Bookmarks
        .Add Range:=aRng, Name:="disclaimer"
        .DefaultSorting = wdSortByName
        .ShowHidden = False
      End With
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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