It would be very nice if Word would let you put up a pull down menu on the
toolbar that had on it a set of fields and identifiers that had already been
used in the document, simplifying insertion of the next seq field (and not
forcing you to remember every identifier that you'd used in the doc).
Does this exist, or where is the best place to request such a feature?
Thanks,
John
--
John Altman
Emory Vaccine Center at Yerkes
954 Gatewood Road
Atlanta, GA 30329
Phone: 404-727-5981
FAX: 404-727-9005
email: alt...@microbio.emory.edu
Nothing like this exists. You could request it at msw...@microsoft.com, but MS
is not usually enamored of revamping its older technology...
What I usually do is create an AutoText field for each SEQ identifier; and if
I'm doing heading levels, AutoText entries of combined SEQ fields for each
level. I'll then use Tools/Customize/Commands; Category: AutoText to create a
toolbar I can use to apply the sequences as they're required.
> It would be very nice if Word would let you put up a pull down menu on the
> toolbar that had on it a set of fields and identifiers that had already been
> used in the document, simplifying insertion of the next seq field (and not
> forcing you to remember every identifier that you'd used in the doc).
>
> Does this exist, or where is the best place to request such a feature?
>
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://go.compuserve.com/MSWord
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
>> It would be very nice if Word would let you put up a pull down menu on the
>> toolbar that had on it a set of fields and identifiers that had already been
>> used in the document, simplifying insertion of the next seq field (and not
>> forcing you to remember every identifier that you'd used in the doc).
>>
>> Does this exist, or where is the best place to request such a feature?
>>
>Hi John,
>
>Nothing like this exists. You could request it at msw...@microsoft.com, but MS
>is not usually enamored of revamping its older technology...
>
>What I usually do is create an AutoText field for each SEQ identifier; and if
>I'm doing heading levels, AutoText entries of combined SEQ fields for each
>level. I'll then use Tools/Customize/Commands; Category: AutoText to create a
>toolbar I can use to apply the sequences as they're required.
Cindy: I haven't got time right now to test it out just now, but
I believe John *can* do this (mind you, I think I prefer your
solution):
1. Use the macro recorder to record the insertion of one each of
the required SEQ fields, giving each macro a suitable name. In
the case of the numbered headings, record the setting of the
heading style plus the insertion of all of the required SEQ
fields.
2. Go to tools -> Customize -> Commands and select New Menu in
the left-hand list.
3. Drag New Menu from the right-hand list and drop it on the
required toolbar. Now right-click on it and rename it to
something like "Seq".
4. Back in the Customize dialog, select Macros in the Commands
list and then, one-by-one, drag the new macros up to the new menu
and drop them on the drop-down that then extends from it.
If your macro names are (like the seq identifiers) none too
self-explanatory, right-click and rename the menu items, too.
5. Close the Customize dialog.
--
Regards
Peter Boulding
P.Bou...@btinternetUNSPAM.com (to e-mail, remove "UNSPAM")
John
in article voc56ssf4frrofe1p...@4ax.com, Peter Boulding at
p.bou...@btinternetUNSPAM.com wrote on 12/23/1999 6:43 PM:
--
The first one is used for the FIRST paragraph in any sequence, the second
for ALL OTHERS. *One* of these days, I will get around to updating these so
they will handle a selection of paragraphs...hang about... today's the
day!!!
End Sub
Sub AddNumberFirst()
'
' AddNumberFirst Macro
' Macro recorded 20/05/98 by John McGhie
'
With Selection
.Collapse
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Fields.Add Range:=Selection.Range, Type:=wdFieldSequence, Text:= _
"numberedlist \r 1 \* Arabic", PreserveFormatting:=True
.TypeText Text:=("." + Chr$(9))
.HomeKey Unit:=wdLine, Extend:=wdExtend
.Fields.Update
.Collapse Direction:=wdCollapseEnd
.Style = ActiveDocument.Styles("Numbered List")
End With
End Sub
Sub AddNumberSubsequent()
'
' AddNumberSubsequent Macro
' Macro recorded 20/05/98 by John McGhie
'
Dim aParagraph As Paragraph
For Each aParagraph In Selection.Range.Paragraphs
aParagraph.Range.Select
With Selection
.Collapse
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Fields.Add Range:=Selection.Range, Type:=wdFieldSequence, Text:= _
"numberedlist \* Arabic", PreserveFormatting:=True
.TypeText Text:=("." + Chr$(9))
aParagraph.Range.Fields.Update
aParagraph.Style = ActiveDocument.Styles("Numbered List")
End With
Next aParagraph
End Sub
On Thu, 23 Dec 1999 11:08:08 -0500, John Altman <alt...@microbio.emory.edu>
wrote:
> After struggling mightily to gain control over some complex numbered lists
> using the autonumbering/bullets facility in Word98 (Mac), I'm ready to
> switch to using seq fields.
>
> It would be very nice if Word would let you put up a pull down menu on the
> toolbar that had on it a set of fields and identifiers that had already been
> used in the document, simplifying insertion of the next seq field (and not
> forcing you to remember every identifier that you'd used in the doc).
>
> Does this exist, or where is the best place to request such a feature?
>
> Thanks,
>
> John
Please post follow-up questions to the newsgroup so that all may follow the thread.
John McGhie <jo...@mcghie-information.com.au>
Consultant Technical Writer
Microsoft MVP (Word)
Sydney, Australia (GMT +10 hrs) +61 (04) 1209 1410
Thanks for your time. I haven't used Word Macros before, so I don't really
understand how these do what they do (or how to modify them), although I
have done as you said. Would you mind explaining them in a bit more detail?
I find that they only work for the style "Numbered List". However, suppose
that I have a couple of different styles that I need to use in the document
(for example different levels of indent, etc....).
Also, they solve the problem of not having to remember identifier names, so
I think they will be useful, but the other proposed solutions have the
advantage (or so it seems) that they let me label the buttons on the toolbar
with identifier names.
Clearly, I have a lot to learn about macros, and even about styles....
Thanks again,
John
--
John Altman
Emory Vaccine Center at Yerkes
954 Gatewood Road
Atlanta, GA 30329
Phone: 404-727-5981
FAX: 404-727-9005
email: alt...@microbio.emory.edu
in article nss56sgkk5qbvgqvp...@4ax.com, John McGhie [MVP -
Word] at jmc...@tpg.com.au wrote on 12/24/1999 2:39 AM:
> John,
>
> Thanks for your time. I haven't used Word Macros before, so I don't really
> understand how these do what they do (or how to modify them), although I
> have done as you said. Would you mind explaining them in a bit more detail?
Hi John:
OK, sorry I did not realise you were feeling your way into this abyss for
the first time :-)
In a moment, I will provide a fully-described copy of the macro. However,
let's deal with your questions first:
You can call the toolbar button for a macro anything you like.
1) After you have the macro on your toolbar, right-click the Toolbar
and choose Customise.
2) Right-click the button for the macro. You will be offered a Name
field. Something I recently realised (last week....) is that this is the
name of the BUTTON, not the name of the function. Change it to anything you
wish.
3) While you are there, you might like to add an Icon to the button.
In this case, why not pinch Microsoft's Numbering icon for the purpose?
4) Right-click the Numbering icon (on any toolbar, doesn't matter: you
can even do it in a different copy of/version of/ Word.
5) Choose Copy button Image
6) Right-click the target button (the new one you just renamed) and
choose Paste Button Image.
7) Now, since this button does not do what the "standard" button does:
you might like to change it to remind yourself that this is the "special"
version. Right-click the button again and choose Edit Button Image. I
usually change the background colour to remind me that this is a special
case.
8) Right-click it again, and decide whether you want the button to
appear with its Icon Only (Default style), with the Icon and Text, or with
Text Only. Choose the appropriate option.
Now, to your question about styles. You are correct that my macros apply
the List Number style. I will show you how to change that in a minute. But
first, let me say that I have discovered that it is important to assign a
style for each specific format.
So, whichever style you choose, you should reserve a style for those
paragraphs that have numbering, and use only that style for numbered
paragraphs. I, and all other documentation professionals that I know,
strongly disagree with the option of having several different formats of
numbering on a single style. There are pros and cons to this approach, but
we find that the cons massively outweigh the pros:
Pro:
It's simpler. Users who do not understand or use styles can get their
numbering the way they want it without having to learn a new concept.
It's the default. This would have been a tricky design decision, but the
designers of Word have discovered through user research that some
astonishingly high percentage (around 90 per cent...) of Word's customers do
not know how to use even very basic features such as styles. And in the
modern corporate environment, they certainly do not have the time to learn.
Con:
Word's multi-level numbering is massively unstable. When you are trying to
fix it, you want to be able to confine your activities to just one "kind" of
numbering at a time.
When you put more than one level of indent on a particular style, one of
them must be a local override to the style. If you ever need to change the
style (and in pro doco work, that's frequently: I have never seen two
successive customers use the same page margins) you then have to hunt down
each individual paragraph and change its local indent as well.
It encourages numbering problems. Word's multi-level numbering "expects"
you to have a DIFFERENT style name assigned to each of its nine "levels".
If you don't, god help you... You can force it to work. But turn your
back, and it's all over the place again...
It won't transport to other formats. Most pro doco people express most of
their output these days on something other than paper. Most software
(including Word's...) that transports stuff to HTML or Acrobat or whatever
determines formatting at the destination by the style NAME and discards the
properties. It does this because the properties are probably inappropriate
at the destination. So if you have three levels of indent all calling
themselves "List Number", your result will contain just one level of indent
with highly-peculiar numbering.
OK. That discussion out of the way, of course I understand that you will
probably want at least Three levels of numbering in a complex document.
What I recommend is that you use three different styles that you create for
yourself. Since it's conventional to do so, I use the styles List Number,
List Number 2, and List Number 3. But I work with highly customised
templates where there is no danger of Word suddenly re-instating the default
formats to those styles. If you use styles you create, you avoid this
likelihood.
When setting up your styles, I strongly suggest that you assign their
Indent, Hanging indent, and tab positions in the style. Base each one on
the one above it, and the first one (let's call it "NumList 1" on your Body
Text style. That way, with a little luck, you will only need to change body
text style if you ever have to reset a document's font.
We "could" assign the indents and tabs in the macro (you can do anything
your heart desires in a macro...) but don't. It leads to maintenance
problems when you can't remember where such-and-such an indent is coming
from. Later, when you get really brave and start experimenting with Word's
built-in numbering, you will find that you have to assign ALL of the
properties in the macro, because Word keeps screwing them up. But let's not
get into that...
DO NOT DEFINE ANY NUMBERING in these styles. If you did, you would end up
with two sets of numbering on your paragraphs.
Having defined the styles, I suggest that you then copy the macros and make
three sets. Later, when you get your confidence with VBA, you will find
that you can do it all with just a single macro to which you pass
parameters. But for macros of this size, there's no advantage in doing so
apart from being able to learn a lot about VBA, so let's keep it simple for
now.
You will need six buttons on the toolbar.
Since you're in the mood, and you are getting good at this Customisation
lark by now, I suggest that now is a good time to do some "weeding" of your
standard toolbars. Read my other post today, titled "Weeding Word's
Toolbars" in microsoft.public.word.newusers for hints.
The Macro
Now, let me walk you through the macro code. Do not attempt to paste this
version into your macro editor. I am going to "explain" the code, rather
than "comment" it. While the macro editor accepts comments, and you should
use lots, it won't accept what I am about to do. Note that I am writing
this for someone coming to programming from the very first time. Since I
know that you are more advanced than this (or you wouldn't have got this
far...) I hope you won't find it too tiresome. Others who are just about to
take the plunge may appreciate the more verbose descriptions.
I am going to take the macro apart line by line. At the bottom is a clean
copy of the code, so you can see what it actually looks like when you paste
it into the VBA Editor. While reading this, I suggest that as I discuss
each statement, you highlight that statement in the VBA editor and hit F1.
This brings up the VBA Help for that specific statement type.
This first line gives the macro its name. If you are making a module that
contains only one macro, change this to "MAIN". If all of your macros are
in a single project, these names need to be unique. It also helps if they
are descriptive. They can't contain spaces.
Sub AddNumberSubsequent()
These next two lines begin with apostrophes. They are comments: free text
the compiler ignores.
' AddNumberSubsequent Macro
' Macro recorded 20/05/98 by John McGhie
'
This "With" construct is new in VBA. It simply allows you to identify what
you are talking about once, then issue a series of commands to it. The
macro recorder uses it a lot: stick with it, it makes your code faster and
more readable.
This next statement is a Dimension statement. It "declares" a "variable".
A "variable" is simply an area of memory the program is going to use to hold
stuff. The declaration gives it a name and tells it what "type" of stuff
we're going to put in there, and how many of them, so Word knows how much
memory to reserve.
Good coders "declare" ALL their variables before they use them, whether they
have to or not. In VBA, it's good practice to declare things: it makes the
program run much faster. But I am a newbie at coding, so I declare my
variables for a much more important reason: it enables the help!!! If you
declare AND type your variable before you use it in your code, Word's VBA
editor will then prompt you through writing each statement by offering the
available options at each step. If you don't declare, or don't assign a
type, Word doesn't find out what this thing is until runtime, so you're on
your own.
In this particular instance, I happen to know that it is not necessary to
declare this variable, and there is no performance advantage in doing so.
Most of the examples you will see of this construct (and it's very
common...) would not declare it here. But I do... If you remove that
particular line, the program will run unchanged.
The statement simply says "create an area of memory called "aParagraph" and
dimension it to contain all the attributes that a Word paragraph can have.
I have followed the recommended VBA naming convention of adding "a" or "my"
or "this" or "the" to the front of the name of the thing the variable will
actually contain. If I had written it as "Dim Paragraph as Paragraph", I
may or may not have gotten away with it. Every compiler has "reserved
words" that the system uses for things: in VBA Paragraph is the reserved
word for ... you guessed it. The VBA compiler is extremely sophisticated
and often smart enough to distinguish a reserved word being used as an
identifier from the same word used in a different context. But it is
stunningly bad practice to rely on this, and leads to all sorts of really
nasty bugs that appear and disappear at random and are nearly impossible to
find. Because I am a really amateur programmer, I simply accept that "they"
must have had a good reason for recommending a naming convention and I do
what I am told...
Dim aParagraph As Paragraph
I had awful difficulty coming to terms with this next statement. It is one
of the most useful in VBA, so you will see it all over the place. It's
"actually" a "For I = 0 to 1000 Do" statement. But Word takes care of
setting up the control structure for you if you specify the "Each" keyword
and tell it which "container" holds "all the things we want to process". In
this case, it is saying "do everything from here down to the "Next
aParagraph" statement to every one of the "paragraphs" that you find in the
"Selection".
Because the "selection" may not actually be exact paragraphs, we ask Word to
take an "intelligent" look. Sort of like saying "Fred, will you get me all
of those books" and pointing to workstation. Fred has enough brains to
bring the books from both the desk and the chair... In this case, the
selection might be no characters, half a paragraph, "only" paragraphs, or
"some" paragraphs and "some other characters".
The qualifier "Selection" tells Word where to begin looking, "Range" tells
Word to include all of the items that the selection touches any part of, and
"Paragraphs" tells Word to fill our bucket only with "paragraphs". No
"characters", thanks, because the logic we are about to write will not know
what to do with "characters".
The reason I had such difficulty understanding this is that you never "see"
either the "bucket" of the control variables, of which there are several.
We just have to take it on faith that somewhere in memory Word creates a
table that contains a pointer to each of the paragraphs the selection
touched.
For Each aParagraph In Selection.Range.Paragraphs
Now, we need to do the same thing to each paragraph, so we want to tell Word
to consider them one-by-one. We start with the variable "aParagraph". In
our declaration, we told Word that this can contain ONLY paragraphs and ONLY
ONE of them, so Word automatically created a structure that enables it to
fill "aParagraph" with the properties of each of the paragraphs in the list
it made in the previous statement. We will cycle through this code as many
times as there are paragraphs in the selection, and each time we get to
here, Word will fill aParagraph with the properties of the next paragraph in
its list. If we change any properties, it will write the changes back to
the actual physical paragraph at the End With statement.
The "For Each" statement is a customised versions of the very common (in
Basic-based languages...) "For ... Next...." construct. In this case, Word
has automatically inserted the qualifier "Each", which means that the VBA
editor has automatically created a whole control structure behind the
scenes. If we think we can do better, we are welcome to write our own (and
if we were writing a large program that was expected to process millions of
lines, we would. But then: we wouldn't choose VBA to write it in in the
first place...). Me, I cheerfully accept all the help I can get: the
automatically-generated programming has a much higher chance of "working"
than the stuff I write. I shall leave "speed and efficiency" to the likes
of Ibby and Jonathan :-)
Recall that we are loading "aParagraph" with all of the properties of each
paragraph in succession. There is an important and obtuse distinction to be
made here which is very important in Object-Oriented languages, and VBA is
one: aParagraph does NOT contain the paragraph itself. It contains ONLY
the "properties" of the paragraph. It contains all the information you
would need to recreate that paragraph, but it does not contain the
paragraph. Now that I have said that it's important, I can tell you that in
this instance, it doesn't matter a toss: but elsewhere in VBA it is usually
essential to understand that we are manipulating an object's description,
rather than the object itself.
The next keyword "Range" selects ONE of the properties in aParagraph. The
"Range" of an object is a string of characters (byte positions, actually)
that exactly encloses the item. To see the effect, triple-click a
paragraph. That's what we have just done. The last keyword on the line is
the Method "Select". If you read Bill Coan's wonderful intro to VBA
programming, you would know that a "Method" is "something which takes an
action". The distinction is not that important right now: just remember
that whenever you want to do something, you will have to use a method, and
to use a method, you first have to walk your way down the Word Document
Object Model until you have exactly defined what it is you want the method
to process.
We have identified a paragraph and selected. Aren't you glad VBA is not as
verbose as I am :-)
aParagraph.Range.Select
This next line is the beginning of a "With ... End With" construct. This is
a convenient shorthand that enables us to identify something once only, then
issue multiple instructions about it. It is particularly useful in more
complex programs when the expression that identifies the thing can go on for
ever, and you wouldn't want to have to type it all out on each line. While
it is mainly a readability aid, the With statement also makes programs run
faster, because Word only has to figure out what we are talking about once.
It then remembers it, rather than having to evaluate our expression on each
line.
With Selection
Note that the following statements all begin with dots: this is required
since each of the statements is actually the "end" of a line that the With
statement began.
The first line, "Collapse" simply collapses the selection to an
insertion-point. This is lazy programming on my part: I wanted to position
the insertion point at the extreme beginning of the paragraph, before any of
the text. I happen to know that if you select a paragraph and then collapse
the selection, that's what happens. But I should really have taken the
trouble to correctly position the selection, instead of relying on default
behaviour. What I have done is inefficient: it causes the computer to have
to do all that selecting then unselecting when it could simply have moved
the selection, and it's dangerous: in the next version of VBA, this default
behaviour of the Collapse statement might change, and my program would
develop a hidden bug that would be very difficult to find. Do as I say, not
as I do...
.Collapse
I would say this next line is a bug :-) I can't remember why I put it
there: since it does exactly the same thing: moves the selection to the
beginning of the paragraph. I shall leave you to remove the Collapse
statement and see if the program still works without it.
StartOf is a method that takes arguments. It moves the selection to the
start of something. You have to tell it what you want to go to the start
of, and whether you want to move just the insertion point or whether you
want to extend the selection. We want to move the insertion point because
we want to insert some text. If we extended the selection, our insertion
would replace the text.
.StartOf Unit:=wdParagraph, Extend:=wdMove
PAY ATTENTION TO THIS BIT! You will have to make changes here :-)
This next statement adds a Field to the text. It first says where, then
what type, then fills it in, and finally sets the field switches.
.Fields.Add Range:=Selection.Range, Type:=wdFieldSequence, Text:= _
"numberedlist \* Arabic", PreserveFormatting:=True
In her very helpful post on the same subject, recall that Cindy suggested
putting the fields in AutoTexts and inserting them. You could equally do
that here. I chose to "create" the field rather than add an autotext since
I know that AutoTexts can exist only in a particular template, and in the
rough-and-tumble of a workgroup, you cannot always rely on everyone's
templates to be fully up-to-date and to thus contain the "correct"
autotexts.
Remember what we're trying to do? After all this waffle I would not be
surprised if you have forgotten :-) We are trying to insert a SEQ field
that looks like this: {SEQ "numberedlist" \* Arabic \MERGEFORMAT}. The
"numberedlist" string is the name of the sequence.
When you copy this macro to do your other two levels of numbering, you MUST
change the "numberedlist" identifier to something else. "numberedlist2" and
"numberedlist3" would be perfect. If you do not change this identifier,
your other macros will simply insert the same SEQ field on their paragraphs.
You will have lists that have different indents but which are members of the
original list. Spaghetti numbering all over again...
The problem that can occur with the autotext method is that someone hops in
to make a quick change to the AutoText and inadvertently assigns a slightly
different name. You then get TWO sets of numbering in the document, which
gives you spaghetti-numbering, and that's where we came into this movie...
Being a paranoid old fart, I put the SEQ field definition in the macro so I
retain total control over what is going on. Yes, I am seeing someone about
my little "control issue"... But in the meantime, it is good practice in
programming to accept TOTAL responsibility for your environment and the
world around you. The rule I was taught was "You either set it, or you have
no idea what it is: so rely on it being the least convenient possibility!"
This next line is easy. The TypeText method does exactly what you and I do,
it types some text :-) In this case, a period followed by a tab character.
That's another bug: I have used the ASCII and Unicode value for a tab
character. That's extremely poor programming practice: my macro will work
only on a PC. I shall leave it to you to change Chr$(9) to "vbTab". vbTab
is a function that "figures out what the tab character should be in this
piece of text and substitutes the correct code."
.TypeText Text:=("." + Chr$(9))
This next statement is laziness on my part. I need to update the field, but
I have lost track of my cursor position. Rather than figure it out, I took
the brute force approach and simply updated all the fields in the current
paragraph. Since I suspect there will usually only be one such field, I am
prepared to cop the performance hit. If you want to do it properly, you
will have to figure out where the insertion point ended up, move it back to
enclose the field, then update just that field. You will note that in the
AddNumberFirst macro, I actually took the trouble to do just that. The
reason we want to update the field is so that we do not confuse the user.
The user expects that when they hit the "Numbering" button, they will get a
string of sequential numbers. If we don't update that field, they won't.
They will get a string of "1"s. The user will then think "they" have done
something wrong, and set out to correct their mistake. The MOST lethal
object in the computer world is a confused and frightened user. You have no
idea what they are going to do, but trust me on this: you are not going to
like it and it is going to be very expensive to repair. I have seen a user
in tears pathetically hitting every key on the keyboard hoping that
something would work. I asked my boss to fire the programmer that got her
into that position. She did. (OK, he was one of these guys you just
couldn't tell...)
aParagraph.Range.Fields.Update
This one is also easy. Remember we have all the "properties" of our
paragraph loaded into "aParagraph"? This is how Word "actually" applies a
style to a paragraph: it changes the name of the Style property of the
paragraph. We can do that...
This is the other place you will need to make a change when you are copying
the macro. Recall my discussion about using a different style for each
level of list? So: "Numbered List", "Numbered List 2", "Numbered List 3".
The style you choose must exist already in either the document or its
template or you will get an error.
aParagraph.Style = ActiveDocument.Styles("Numbered List")
This just signs off the With statement. It must be there or you get an
error.
End With
And this statement is the end of the loop structure that began with the
"For" statement. This marks the boundary between all the statements that
are executed once for each selected paragraph, and the other statements in
the macro, which are executed once only, not on each paragraph.
I have followed the suggested convention of naming the control variable for
the For...Next statement in the Next line. You don't have to, the compiler
ignores it if you do. But if there are multiple "For" statements in a macro
(and there often are) this makes it easy to see which ONE you are closing
here.
You will not appreciate the benefits of well laid-out, properly commented
code until the first time you open a macro and scream "Who wrote this
shit!?!?!?", and then realise, with dawning horror, that it was you. And
you have half an hour to fix it. And you haven't a clue how it works...
Next aParagraph
This next statement tells the compiler where the end of the subroutine is.
In this case, the macro has only one subroutine, so this is actually the end
of the macro. And because the macro has only one routine, we could just as
easily have called it "MAIN" up the top. If we are going to make this macro
a separate piece of text, we SHOULD do that. I've done that for the clean
copy appended below:
End Sub
Here's a clean copy of the code with no narrative:
Sub MAIN()
'
' AddNumberSubsequent Macro
' Macro recorded 20/05/98 by John McGhie
'
Dim aParagraph As Paragraph
For Each aParagraph In Selection.Range.Paragraphs
aParagraph.Range.Select
With Selection
.Collapse
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Fields.Add Range:=Selection.Range, Type:=wdFieldSequence,
Text:= _
"numberedlist \* Arabic", PreserveFormatting:=True
.TypeText Text:=("." + Chr$(9))
aParagraph.Range.Fields.Update
aParagraph.Style = ActiveDocument.Styles("Numbered List")
End With
Next aParagraph
End Sub
Hope this helps someone.