Create a toggle button for restart/continue list

C

COE

Hi Folks,

I am using Word 2000, which seems to have no easy method of
restarting/continuing lists without entering the Bullets & Numbering Box.

I am trying to create a toggle macro that will restart/continue numbering or
return an error if the text has no number. But as I have no programming
experience at all, I'm getting a bit lost!

From my travels through VBA Help, I've patched together something that will
restart numbering, but will not continue it and I can't quite work out how to
include the error message for no numbering.

Here's my (attempt at) code:

Sub testlistrestart()
'
' testlistrestart Macro
' Macro recorded 28/10/2005 by COE
' Toggle macro for button on toolbar to continue/restart list numbering

Dim CurrentLT
Dim temp

Set CurrentLT = Selection.Range.ListFormat

temp = CurrentLT.CanContinuePreviousList(ListTemplate:=CurrentLT.ListTemplate)
If temp <> wdContinueDisabled Then
CurrentLT.ApplyListTemplate ListTemplate:=CurrentLT.ListTemplate, _
ContinuePreviousList:=False
Exit Sub
If Not temp <> wdContinueList Then
CurrentLT.ApplyListTemplate ListTemplate:=CurrentLT.ListTemplate, _
ContinuePreviousList:=True
End If
Else
MsgBox "The current text has no numbering!"
End If

End Sub

Any help/pointers for someone just beggining to use VBA would be
appreciated. I tried to use a Not statement for the toggle because from the
examples I've seen it looks much tidier, but I don't know how I would use it
for this macro.

Cheers,
COE
 
S

Stefan Blom

See http://word.mvps.org/FAQs/Numbering/ListRestartFromVBA.htm

--
Stefan Blom
Microsoft Word MVP


in message
Hi Folks,

I am using Word 2000, which seems to have no easy method of
restarting/continuing lists without entering the Bullets & Numbering Box.

I am trying to create a toggle macro that will restart/continue numbering or
return an error if the text has no number. But as I have no programming
experience at all, I'm getting a bit lost!

From my travels through VBA Help, I've patched together something that will
restart numbering, but will not continue it and I can't quite work out how to
include the error message for no numbering.

Here's my (attempt at) code:

Sub testlistrestart()
'
' testlistrestart Macro
' Macro recorded 28/10/2005 by COE
' Toggle macro for button on toolbar to continue/restart list numbering

Dim CurrentLT
Dim temp

Set CurrentLT = Selection.Range.ListFormat

temp = CurrentLT.CanContinuePreviousList(ListTemplate:=CurrentLT.ListTemplate
)
If temp <> wdContinueDisabled Then
CurrentLT.ApplyListTemplate
ListTemplate:=CurrentLT.ListTemplate, _
ContinuePreviousList:=False
Exit Sub
If Not temp <> wdContinueList Then
CurrentLT.ApplyListTemplate
ListTemplate:=CurrentLT.ListTemplate, _
 
C

COE

ooo bum, I forgot about that article.

Well, maybe trying it myself was 'character building' :)

Thanks Stefan.
 
S

Stefan Blom

I'm glad I could point you in the right direction.

I'm not sure if macro programming can be character building, but it
wouldn't surprise me. <g>

--
Stefan Blom
Microsoft Word MVP


in message
 
C

COE

Hmmm, I have just one problem with this macro.

As soon as I put in the arglist (Optional Scope As Range), then the macro
disappears from my list of macros.
Yet if I remove it, then of course I get an error.

What could be going on there?

CHeers,
COE
 
S

Stefan Blom

The problem you're having is caused by the fact that you cannot run a
sub or function which requires parameters from the Macros dialog box;
instead, it must be called from a sub-routine.

However, to get specific help with the code at
http://word.mvps.org/FAQs/Numbering/ListRestartFromVBA.htm, you need
someone who is an expert of VBA. Ask for help in a separate message.

--
Stefan Blom
Microsoft Word MVP


in message
 
C

COE

Thanks Stefan.
I've patched together some code that does half of what I want (ie it
restarts my Style based numbering).
Now for the hard bit - getting it to work as a toggle button!
I'll send a seperate message if (when!) I need help.

Thank you very much.
 

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