Results 1 to 3 of 3
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VBA Statements (Word XP)

    How about:

    Selection.GoTo what:=wdGoToBookmark, Name:="bmk1"

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Statements (Word XP)

    hi Jeanie,

    <pre>Sub CopyTextFromBookMarkToBookMark()
    Dim BMRange As Range
    Set BMRange = _
    ActiveDocument.Bookmarks("InsertBody").Range
    BMRange.Text = _
    ActiveDocument.Range _
    ( _
    Start:= _
    ActiveDocument.Bookmarks("BodyStart").Range.End, _
    End:= _
    ActiveDocument.Bookmarks("BodyEnd").Range.Start _
    ).Text
    ActiveDocument.Bookmarks.Add Name:="InsertBody", Range:=BMRange
    End Sub
    </pre>



    as you know, you can set a bookmark to contain a range, you don't need two bookmarks to indicate start and end of that range, unless you have a specific reason to do so.
    see also this thread

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    VBA Statements (Word XP)

    I was making this too hard--just used the following:

    Selection.GoTo What:=wdGoToBookmark, Name:="Body"
    Selection.Find.ClearFormatting
    Selection.Copy
    Selection.GoTo What:=wdGoToBookmark, Name:="InsertBody"
    Selection.Find.ClearFormatting
    Selection.PasteAndFormat (wdPasteDefault)
    __________
    I need to copy data from one location in a document to another. The data is bookmarked at the start and end. There is another bookmark (InsertBody) where I need the text copied to. I have defined the range as

    ActiveDocument.Range(Start:=ActiveDocument.Bookmar ks("BodyStart").Range.End, End:=ActiveDocument.Bookmarks("BodyEnd").Range.Sta rt).Text.Copy


    I'm not sure how to efficiently go to the next bookmark and insert the text...I haven't used VBA for about 3 years. I'll be hitting the books again this week!

    Thanks,

    Jeanie

Posting Permissions

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