issue with list number in VBA

A

Associates

Hi,

I am having difficulty in getting the list numbering to work. In a document,
i have macro that inserts bullets and numbers point. The idea was to be able
to keep them both in the same alignment as described in the examples below
(notes: o indicates a solid dot bullet)

For example
....
1. testing1
2. testing2

o testing1
o testing 2

rather than by default, word does the following
1. testing1
2. testing2

o testing1
o testing2

so i managed to get it to work with the help of other codes and to force
re-start the number but with a bit of problem as follows (note: | denotes the
mouse cursor)

1. testing1
2. testing2
|
|

and to bring the cursor back to its original position, i have to press
"backspace" key twice and change the style to Normal.

My question is how to change the style back from "List Number 2" to Normal
in VBA when user finishes with the list number point

Here is the code i have got

Sub addnumberpoint()

Selection.Style = ActiveDocument.Styles("List Number 2")
Call RestartListNumbering

End Sub

Public Sub RestartListNumbering(Optional Scope As Range)
'Public Sub RestartListNumbering(Optional Scope As Range)
'(c) 1999-2004 Word Heretic (e-mail address removed)
' Everyone has permission to redistribute and use this code at will,
' providing the (c) notice is left intact.
'Restarts list numbering, 97-XP, all list implementations

Dim KillScope As Boolean

If Scope Is Nothing Then
Set Scope = Selection.Range

KillScope = True
End If

'Use first listparag
With Scope.ListParagraphs
If .Count > 0 Then
With .Item(1).Range.ListFormat
.ApplyListTemplate .ListTemplate, False
End With
End If
End With

'Destroy our objects
If KillScope Then Set Scope = Nothing

End Sub
 
J

Jean-Guy Marcil

Associates said:
Hi,

I am having difficulty in getting the list numbering to work. In a document,
i have macro that inserts bullets and numbers point. The idea was to be able
to keep them both in the same alignment as described in the examples below
(notes: o indicates a solid dot bullet)

For example
...
1. testing1
2. testing2

o testing1
o testing 2

rather than by default, word does the following
1. testing1
2. testing2

o testing1
o testing2

so i managed to get it to work with the help of other codes and to force
re-start the number but with a bit of problem as follows (note: | denotes the
mouse cursor)

1. testing1
2. testing2
|
|

and to bring the cursor back to its original position, i have to press
"backspace" key twice and change the style to Normal.

My question is how to change the style back from "List Number 2" to Normal
in VBA when user finishes with the list number point

I do not understand the problem you are having.
All the code you have does is apply a style and restart the numbering.

Why would you want to change the style you just applied back to Normal?
 

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