"Find" an autonumber with a macro?

E

Ed

I'm trying to help my son over the phone. He's got Word 2000 on Windows
2000. He's just discovered recording macros. He's working on formatting a
multiple choice test for the school he works at, and he wants to record a
macro that will find every autonumbered answer "d.", go to the end of the
line, and put an extra line break in. I can help him with everything else,
but I can't seem to get "Find" to see the autonumbers. Any help is welcome.

Ed
 
S

Shauna Kelly

Hi Ed

Let's go back and work out what he wants to achieve. My guess is that he has
something like:

Q. What is the capital of Australia?
(a) Sydney
(b) Melbourne
(c) Canberra
(d) Adelaide

Q. Next question....

And what he really wants is space between the (d) response and the question.
Or, to put it terms useful for Word, he wants space before each Question.

Is that the issue?

If so, then the best way is to create a new style called, say, Question.
Modify the style to have an appropriate amount of Space Before, and apply it
to each question. It would be a good idea to format this style with "Keep
with next". If you do that, Word will always keep this paragraph on the same
page as the next paragraph. So (unless you leave an empty paragraph between
the Question and the first response), the Question will never dangle alone
at the bottom of a page.

For more information on applying and modifying styles see

How to apply a style in Microsoft Word
http://www.ShaunaKelly.com/word/styles/ApplyAStyle.html

How to modify styles in Microsoft Word
http://www.ShaunaKelly.com/word/styles/ModifyAStyle.html


If there are many questions, and each question starts in a systematic way,
then you can use Edit > Replace to apply the style. Click the More button to
see the list of styles.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
E

Ed

Hi, Shauna. You've got it exactly. Unfortunately, while the Styles
solution would indeed be the best,
If there are many questions, and each question starts in a systematic way,
then you can use Edit > Replace to apply the style.
I don't think "systematic" applies. Someone else typed it and give it to
him with instructions to "make it look like this". And the only
"systematic" thing is - they all start with a "top level" autonumber! so
then he's stuck going through each question on every teacher's test paper
applying the style to each question - and dealing with any problems that may
cause to the autonumbering.

Is there any hope?

Ed
 
K

Klaus Linke

Hi Ed,

Something like this should do the trick:
(make a backup first!)

Dim myPara As Paragraph
Dim myRange As Range
Set myRange = Selection.Range.Duplicate
For Each myPara In myRange.Paragraphs
If myPara.Range.ListFormat.ListString Like "[a-d]." Then
myPara.Style = ActiveDocument.Styles(wdStyleListNumber)
End If
Next myPara

It applies the "List Number" style, which you could then modify if
necessary.

To apply some other style, use the style name in quotes instead of
wdStyleListNumber:
myPara.Style = ActiveDocument.Styles("MyListStyle")

Regards,
Klaus
 
E

Ed

Thank you, Klaus! It works great!
Ed

Klaus Linke said:
Hi Ed,

Something like this should do the trick:
(make a backup first!)

Dim myPara As Paragraph
Dim myRange As Range
Set myRange = Selection.Range.Duplicate
For Each myPara In myRange.Paragraphs
If myPara.Range.ListFormat.ListString Like "[a-d]." Then
myPara.Style = ActiveDocument.Styles(wdStyleListNumber)
End If
Next myPara

It applies the "List Number" style, which you could then modify if
necessary.

To apply some other style, use the style name in quotes instead of
wdStyleListNumber:
myPara.Style = ActiveDocument.Styles("MyListStyle")

Regards,
Klaus


Ed said:
Hi, Shauna. You've got it exactly. Unfortunately, while the Styles
solution would indeed be the best,
I don't think "systematic" applies. Someone else typed it and give it to
him with instructions to "make it look like this". And the only
"systematic" thing is - they all start with a "top level" autonumber! so
then he's stuck going through each question on every teacher's test paper
applying the style to each question - and dealing with any problems that
may cause to the autonumbering.

Is there any hope?

Ed
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top