PDA

View Full Version : Parsing a Word Doc - a real simple question



Billy Bunter
05-07-2007, 07:03 AM
Hi All

I have a bug to fix and I need to do some VBA work - something I haven't done before.

I need to parse a Word Doc, search for a particular string pattern, and assign the value of that string pattern to a variable within the loop (to do something else with it). I can see from existing code that the following is used to find something: ActiveDocument.Content.Find.Execute...
but I also need it to return what it finds. The string pattern is this:
{{some_text_value_here}}

So, I need the code that loops through the doc, search for the pattern, and assigns that value of the pattern to a variable.

Can someone help - I'm sure it's just a few lines of code.

Many thanks

--Billy Bunter

qazpl
05-07-2007, 07:15 AM
Do you wan't to return a range object or a string
checkout http://www.vbaexpress.com/forum/showthread.php?t=9732

Billy Bunter
05-07-2007, 07:47 AM
Thanks very much!

BB

Billy Bunter
05-07-2007, 01:47 PM
Do you wan't to return a range object or a string


Sorry, in my haste I didn't read your response very well nor did I read the other thread very well.

What I want is to return the text between two identifiers (or tokens):

{{ and }}.

What I want is the string between the two tokens.

Any ideas?

Thanks

--BB

mdmackillop
05-08-2007, 05:40 AM
Assigning to a variable could be a problem, but you could store them in an array. See this item (http://vbaexpress.com/forum/showthread.php?t=12533)

Billy Bunter
05-08-2007, 01:58 PM
That looks more like it. Thank you.