A
Associates
Hi,
Just wondering if in word VBA, there is any way of knowing when users
finishes with the list bullet points.
I know that usually by pressing "enter" key twice, the word ends the list
and move the insertion cursor back to the very left alignment as follows
some texts
1. cats
2. dogs
| <--- insertion point
What i wanted to be able to do is to write a macro to allow users to insert
list bullets and list numbers. I have customised the list number (e.g. List
Number 2) in such a way that they are always indented in the same alignment
as shown below
1. cats
2. dogs
1. Michael
2. Andy
3. George
I know that the second list numbers, by default, would usually be indented a
bit further but the above is what i wanted.
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. cats
2. dogs
|
|
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
Just wondering if in word VBA, there is any way of knowing when users
finishes with the list bullet points.
I know that usually by pressing "enter" key twice, the word ends the list
and move the insertion cursor back to the very left alignment as follows
some texts
1. cats
2. dogs
| <--- insertion point
What i wanted to be able to do is to write a macro to allow users to insert
list bullets and list numbers. I have customised the list number (e.g. List
Number 2) in such a way that they are always indented in the same alignment
as shown below
1. cats
2. dogs
1. Michael
2. Andy
3. George
I know that the second list numbers, by default, would usually be indented a
bit further but the above is what i wanted.
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. cats
2. dogs
|
|
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