Macro to "start numbering from"?

C

Clive Huggan

Dear all,

I would like to write a macro to open the pane that appears when one chooses
Format -> Style -> Modify -> Numbering -> Outline numbering -> Customize
(the pane is titled "Customize outline numbering list").

My aim is to have this pane open so that the "Start at:" field can be filled
in with a number that will depend on where an individual document goes in a
sequence. We need human intervention to determine the number that's entered.

I could not get the macro to complete by recording the sequence, and I can't
find any command in the "All commands list". I will be grateful indeed to
find out how to do it.

Cheers,

Clive Huggan
Canberra, Australia
(My time zone is at least 5 hours different from the US and Europe, so my
follow-on responses to those regions can be delayed)
============================================================
 
J

John McGhie

Hi Clive:

Ahhh.... So THAT¹s where your document corruption is coming from :)

Try these (courtesy of Steve Hudson...)

Sub RestartNumber()
With Selection.Paragraphs
If .Item(1).Range.ListFormat.ListTemplate Is Nothing Then End
With .Item(1).Range.ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End With
End Sub

Sub ContinueNumber()
With Selection.Paragraphs
With .Item(1).Range.ListFormat
.ApplyListTemplate .ListTemplate, True
End With
End With
End Sub

The first starts the existing list at ³1². The second continues it from the
one above.

To do what you really want, try this:

Sub SetStartingNumber()

Const Prompt As String = "Type the starting number."
Const Title As String = "Set Starting Number Macro"

Dim aStyle As Style
Dim n As Long
Dim Default As Long
Dim Button As Integer

With Dialogs(wdDialogFormatStyle)
Button = .Display ' Enables choice of style
Set aStyle = ActiveDocument.Styles(.Name) ' Stores what you chose
End With

If Button <> 0 Then ' User didn't cancel
With aStyle
n = ActiveDocument.Styles(aStyle).ListLevelNumber ' Gets the list
level of the style
' Returns the list template's list level and prompts for a starting
number

If n > 0 Then
Default = .ListTemplate.ListLevels(n).StartAt
.ListTemplate.ListLevels(n).StartAt = _
InputBox(Prompt, Title, Default)
End If

End With
End If
End Sub


I haven¹t even checked that that will compile in Mac Word...

Good grief! It not only compiles, it works :) If you click in a paragraph
it will prompt for the style name, which defaults to the style on the
paragraph you clicked in. If you then click ³Apply², you will not apply the
style, instead, the macro will check that numbering is already applied to
the style. If it is, you will be invited to set the starting number for
that level of heading. If there is no numbering applied, the macro will
silently do nothing. You might care to cut in a helpful explanatory message
and repost...

I¹m off to bed!!

Beth, you might like to throw those three macros plus my other two up on the
website: it¹s time the Mac section had some serious code to make the
unwashed lot jealous :)

Cheers


Dear all,

I would like to write a macro to open the pane that appears when one chooses
Format -> Style -> Modify -> Numbering -> Outline numbering -> Customize
(the pane is titled "Customize outline numbering list").

My aim is to have this pane open so that the "Start at:" field can be filled
in with a number that will depend on where an individual document goes in a
sequence. We need human intervention to determine the number that's entered.

I could not get the macro to complete by recording the sequence, and I can't
find any command in the "All commands list". I will be grateful indeed to
find out how to do it.

Cheers,

Clive Huggan
Canberra, Australia
(My time zone is at least 5 hours different from the US and Europe, so my
follow-on responses to those regions can be delayed)
============================================================

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
B

Beth Rosengard

Hi John,

I'll work on this once I'm on the other side of November :), but you'll
need to give me a title and short description of each of the macros.

Cheers,

Beth
 
C

Clive Huggan

Inline.

Hi Clive:


Future tense, please ‹ this is my first doc with auto numbering, following
years of shrewd avoidance! I can quote your ³Word¹s numbering explained² and
Shauna¹s web page off by heart now. ;-)



Gee, if I had known you were up at almost midnight I could have hopped in the
car and banged on your door!

Many thank, John ‹ looks like just what I need, including the fact that I
didn¹t know some of what I needed...

Cheers,

Clive
 

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