How can I collect a list of tags from a document and build a list ofthem for filling a ComboBox from

Discussion in 'Word VBA' started by Ricky Marek, Oct 16, 2013.

  1. Ricky Marek

    Ricky Marek Guest

    How can I get a list of unique tags collected from a document by running a search operation.

    The tags are composed a single word enclosed by '[#' and ']' or '[!' and ']'.
    For example [#ABC], [#FOO], [!FOO], [!BAR], [!WXYZ].

    The tags may appear more than once in the document, therefore I should ignore the duplicated ones and build a unique list of tags. (The tags collected from the example above would be "ABC", "BAR", "FOO", "WXYZ")

    It would be nice to have them sorted as well :)

    The idea is to generate the list and use it to fill a user form combo box, filled dynamically.

    Can you give an idea how to run this?

    The code I was using is similar to:

    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
    .Text = "(\[[!#])(*)(\])"
    .Replacement.Text = ""
    .Wrap = wdFindContinue
    .MatchWildcards = True
    End With

    But this runs on all the document and removes the tag.. How do I do for collecting the tag without removing?


    Thanks in advance.

    --- Ricky Marek.
     
    Ricky Marek, Oct 16, 2013
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Eric
    Replies:
    6
    Views:
    155
    Jonathan West
    Jun 4, 2004
  2. Herve cadieu
    Replies:
    0
    Views:
    161
    Herve cadieu
    Mar 2, 2005
  3. Magnus
    Replies:
    1
    Views:
    265
    Word Heretic
    Mar 18, 2005
  4. Dennis
    Replies:
    11
    Views:
    159
    Jean-Guy Marcil
    May 17, 2005
  5. Ocean
    Replies:
    0
    Views:
    133
    Ocean
    Nov 22, 2005
  6. Cissy

    Using forms to collect information

    Cissy, Feb 9, 2006, in forum: Word VBA
    Replies:
    2
    Views:
    118
    Charles Kenyon
    Feb 10, 2006
  7. Sam
    Replies:
    3
    Views:
    151
    Cindy M -WordMVP-
    Apr 20, 2006
  8. Mickey

    Macro o collect titles and dates

    Mickey, Aug 1, 2007, in forum: Word VBA
    Replies:
    2
    Views:
    117
    Mickey
    Aug 6, 2007
Loading...