-
Notifications
You must be signed in to change notification settings - Fork 0
/
a1_createAbntStyles.bas
186 lines (135 loc) · 4.62 KB
/
a1_createAbntStyles.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Attribute VB_Name = "a1_createAbntStyles"
Sub createAbntStyles(control As IRibbonControl)
Call eraseCustomStyles
Call reducePriority
Call createFontSizeName(styleName:="New normal")
Call createBody(styleName:="Corpo do texto")
Call createNonNumberedTitle(styleName:="Título fora do sumário")
Call createNonNumberedTitle(styleName:="Título não numerado")
Call createNumberedTitle(styleName:="Título")
Call create_list
End Sub
Sub reducePriority()
Set oStyles = Application.ActiveDocument.Styles
For Each Style In oStyles
If Style.Priority < 50 Then
Style.Priority = (Style.Priority + 50)
End If
Next Style
End Sub
Sub createFontSizeName( _
styleName As String, _
Optional ByRef fontSize As Integer = 12, _
Optional ByRef fontName As String = "Arial" _
)
'
' Cascade level 0
'
Set oStyles = _
Application.ActiveDocument.Styles
oStyles.Add _
Name:=styleName, Type:=wdStyleTypeParagraph
With oStyles(styleName)
.BaseStyle = "No Spacing"
.QuickStyle = True
.UnhideWhenUsed = False
.Visibility = False
.Priority = 1
.LanguageID = 1046
AutomaticallyUpdate = True
With .Font
.Name = fontName
.Size = fontSize
End With
End With
End Sub
Sub createBody( _
styleName As String, _
Optional ByRef fontSize As Integer = 12, _
Optional ByRef fontName As String = "Arial" _
)
'
' Cascade level 1
'
Call createFontSizeName(styleName, fontSize, fontName)
With Application.ActiveDocument.Styles(styleName)
.NextParagraphStyle = "Corpo do texto"
With .ParagraphFormat
.Alignment = wdAlignParagraphJustify
.LineSpacing = LinesToPoints(1.5)
.SpaceAfter = LinesToPoints(1)
End With
End With
End Sub
Sub createNonNumberedTitle( _
styleName As String, _
Optional ByRef fontSize As Integer = 12, _
Optional ByRef fontName As String = "Arial" _
)
'
' Cascade level 2
'
Call createBody(styleName, fontSize, fontName)
With Application.ActiveDocument.Styles(styleName)
.Priority = 2
With .Font
.Bold = True
.AllCaps = True
End With
With .ParagraphFormat
.Alignment = wdAlignParagraphLeft
.SpaceBefore = LinesToPoints(2)
.SpaceAfter = LinesToPoints(2)
End With
End With
End Sub
Sub createNumberedTitle( _
styleName As String, _
Optional ByRef fontSize As Integer = 12, _
Optional ByRef fontName As String = "Arial" _
)
'
' Cascade level 3
'
'
' Create a new list template
'
Dim strFormat As String
strFormat = ""
For intLoop = 1 To 4
Call createNonNumberedTitle(styleName & " " & intLoop, fontSize, fontName)
With ActiveDocument.Styles(styleName & " " & intLoop)
.Priority = 3
Select Case intLoop
Case 1
With .ParagraphFormat
.SpaceBefore = LinesToPoints(2)
.SpaceAfter = LinesToPoints(2)
End With
Case 2
With .ParagraphFormat
.SpaceBefore = LinesToPoints(2)
.SpaceAfter = LinesToPoints(1)
End With
Case 3
With .ParagraphFormat
.SpaceBefore = LinesToPoints(1.5)
.SpaceAfter = LinesToPoints(0)
End With
With .Font
.Bold = False
.AllCaps = True
End With
Case 4
With .ParagraphFormat
.SpaceBefore = LinesToPoints(1.5)
.SpaceAfter = LinesToPoints(0)
End With
With .Font
.Bold = False
.AllCaps = False
End With
End Select
End With
Next intLoop
End Sub