Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Sun, 28 Sep 2008 15:52:01 -0700,    group: microsoft.public.word.vba.general        back       


customise list number   
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 steve@wordheretic.com
    ' 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
date: Sun, 28 Sep 2008 15:52:01 -0700   author:   Associates

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us