|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Sub udfStyleLockton()
'
'Chris and Gary
'
' My cut at this differs in a few ways
' 1. includes multiple paragraphs (in case the text has already been typed)
' 2. makes the numbering restart afresh
' 3. removes the Jason tab that introduces itself (in the words of Austin "Allow
' myself to introduce... myself)
' 4. Lines the number (not the left indent) up with the text above
'
' Andrew Lockton
' Chrysalis Design Pty Limited
' Melbourne Australia
Dim myRange As Range
Dim sngleftIndent As Single
Dim MyList As ListFormat
With Selection 'include the entire selected paragraphs
.StartOf Unit:=wdParagraph, Extend:=wdExtend
.EndOf Unit:=wdParagraph, Extend:=wdExtend
End With
Set myRange = Selection.Range
'Apply a predefined style formats
myRange.Style = ActiveDocument.Styles("List Number 2")
'Make the list restart numbering
Set MyList = myRange.ListFormat
MyList.ApplyListTemplate ListTemplate:=MyList.ListTemplate, ContinuePreviousList:=False
'Now apply local indentation
With Selection ' go back one paragraph
.Collapse Direction:=wdCollapseStart
.Move Unit:=wdParagraph, Count:=-1
sngleftIndent = .ParagraphFormat.LeftIndent ' obtain parent indentation
End With
myRange.ParagraphFormat.LeftIndent = sngleftIndent - myRange.ParagraphFormat.FirstLineIndent ' apply parent indentation
'Remove the Jason tab that crept in
myRange.ParagraphFormat.TabStops.ClearAll
'Clear the air
Set myRange = Nothing
Set MyList = Nothing
End Sub
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |