PDA

View Full Version : any suggestions.



qr_doc_con
07-02-2011, 08:37 PM
I've designed this macro to add a numberlist style when i click on a custom toolbar button.

What I would like it to do is have the last part of the name of the style to start at 1.

any suggestions whould be great.


Global textpos As Long
Global numpos As Long
Global tabpos As Long
Global fontRGB As Long
Global stycount As Long
Global lstnum As Integer
Global oListTemplate As ListTemplate
Global sListTemplateName As String
Global numsty As Long
Global txt As String
Global num As String

Public Sub Numberlist()
frm_numberlist.Show 'this is where you set either a 123 or abc numberlist and if its indended or not

'sets varibales
fontRGB = RGB(80, 80, 80) 'set border colour variable based on Red/Green/Blue colour code
textpos = CentimetersToPoints(txt) ' this sets where the text starts and should be the same as the tabpos varible
numpos = CentimetersToPoints(num) ' this sets where the listnumber sits
tabpos = CentimetersToPoints(txt) ' this sets where the tab stop sits
lstnum = ActiveDocument.Styles.Count + 1
sListTemplateName = "oListNumberTemplate" & CStr(lstnum)

On Error Resume Next
Set oListTemplate = ActiveDocument.ListTemplates(sListTemplateName)
If Err.Number <> 0 Then
Set oListTemplate = ActiveDocument.ListTemplates.Add(OutlineNumbered:=False)
oListTemplate.Name = sListTemplateName
End If
On Error GoTo 0

DefineHeadingStyles

DefineListTemplate oListTemplate
End Sub
Public Sub DefineHeadingStyles()
ActiveDocument.Styles.Add ("Numbered List " & CStr(lstnum))
With ActiveDocument.Styles("Numbered List " & CStr(lstnum))
.AutomaticallyUpdate = False '
.LanguageID = wdEnglishAUS ' sets the language to English Au
With .Font
.Bold = False ' turns on Bold Text
.Italic = False ' turns off Italic Text
.Color = fontRGB 'Change font to Grey via variable
.AllCaps = False 'Remove all caps
.Size = 11 ' sets font size
.Name = "arial" 'sets type of font
End With
With .ParagraphFormat
.Alignment = wdAlignParagraphJustify 'Align to lef
.SpaceBefore = 3 ' sets the paragraph spacing above the text
.SpaceAfter = 3 ' sets the paragraph spacing below the text
.LineSpacing = 12 ' sets line spacing to single
End With
End With

End Sub
Public Sub DefineListTemplate(oListTemplate As ListTemplate)

With oListTemplate.ListLevels(1)
.NumberFormat = "%1)" 'this sets the look of the number list
.NumberStyle = numsty ' this is the number style variable
.TextPosition = textpos ' this is the text variable
.ResetOnHigher = 0 'this must be zero
.StartAt = 1 ' this sets what number the list starts at
.NumberPosition = numpos ' this is the list number varible
.TabPosition = tabpos ' this is the Tab stop varible
.Alignment = wdListLevelAlignRight 'this right aligns the numbers
.LinkedStyle = "Numbered List " & CStr(lstnum) ' this links the numberlist to the style set above
End With
End Sub