PDA

View Full Version : how to embed selection into text, that includes the original selection?!



fai_013
01-15-2011, 07:33 AM
Hi All,

I'm trying to wrap my head around how to do the following in MS Word 2000. Below is a sample of the document before the macro. Its like a simple multiple choice questionnaire.

Q3a. How many umbrellas do you have?

6 umbrellas
7 umbrellas
8 umbrellas
9 umbrellas or more

Q3b. What are the colours of your umbrellas?

red
blue
green
multicolored

S4. Which direction do you think umbrella fashion is going?

w surreal
x classic
y modern
z minimal


I plan to select each question, and then change them one at a time using a macro. The multiple choice responses below the question will remain untouched. The dark red text are the new additions, and are always the same. In the end, it should look like this

*LL Q3a L=2 M=1 N=1
[Q3a. How many umbrellas do you have?]
*SL Q3a

1 umbrella
2 umbrellas
3 umbrellas
4 umbrellas or more


*LL Q3b L=2 M=1 N=1
[Q3b. What are the colours of your umbrellas?]
*SL Q3b

1 red
2 blue
3 green
4 multicolored



*LL S4 L=2 M=1 N=1
[S4. Which direction do you think umbrella fashion is going?]
*SL S4

1 surreal
2 classic
3 modern
4 minimal


I know that I can find the Q3a (without the period at the end) with the following code:

With Selection.Find
'Clear the formatting
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
'Find word begining with a letter Q then any # of characters then
' ending with a lower case letter
.Text = "<[Q]*[a-z]"

But then I can't use this "find" for question S4 since it doesn't start with a Q. Can anyone help me with this problem. If I can solve this problem, I can use the solution to solve all of my other issues, which all seem to revolve around finding things in a selection, and then using those found things in some type of mixture of of other codes.

macropod
01-17-2011, 12:10 AM
Hi fai13,

I see you've cross-posted the same Q at: http://www.tek-tips.com/viewthread.cfm?qid=1634504&page=1
(where I've already provided an answer)

For cross-posting etiquette, please see: http://www.excelguru.ca/node/7