Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting a flag into rtf with vba (VBA for Word 97/2000)

    Is it possible to use vba to insert a flag into the rtf of a Word document that can later be found by VBA?

    For instance, can I select text and put a flag at the beginning and end of the text I selected? I would want the flag (or whatever it should be called) to not affect the text, but be found by vba at a later time, so that I can perform some actions on that selection.

    Thanks for your help!!
    Troy

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Inserting a flag into rtf with vba (VBA for Word 97/2000)

    Use the bookmarks. To work out the code...
    Record the act of creating a bookmark and then the act of GoTo for a bookmark. That should give you all you need to work with.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting a flag into rtf with vba (VBA for Word 97/2000)

    The problem with bookmarks is you can only assign them to one location. What I didn't mention before is that I want to be able to use the same flag for different locations. <img src=/S/flee.gif border=0 alt=flee width=25 height=25>

    I could use a character style (and probably I will at first), but that will be a problem if the text already contains a character style.

    Thanks again!!
    Troy

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Inserting a flag into rtf with vba (VBA for Word 97/2000)

    Troy

    I would still use bookmarks but increment the number for each separate bookmark. Then you can cycle through the bookmarks to select each one which starts with xxx to "GoTo" and process. Here is a simple example
    <pre>Sub temp2()
    Dim x As Variant
    For Each x In ActiveDocument.Bookmarks
    If Left(x, 4) = "Text" Then
    x.Select
    End If
    Next x
    End Sub</pre>

    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
  •