Thursday, September 06, 2007

Tools - Word Headers

A set of macros to simplify the use of heading styles in Word:

Sub StyleToHeading1()
Selection.Style = ActiveDocument.Styles("Heading 1")
End Sub

Sub StyleToHeading2()
Selection.Style = ActiveDocument.Styles("Heading 2")
End Sub

Sub StyleToHeading3()
Selection.Style = ActiveDocument.Styles("Heading 3")
End Sub

Sub StyleToHeading4()
Selection.Style = ActiveDocument.Styles("Heading 4")
End Sub

Sub StyleToHeading5()
Selection.Style = ActiveDocument.Styles("Heading 5")
End Sub

Assign these macros to ctrl-shift-[1-5] and keeping documents correctly formatted gets a lot simpler.

You can do this by using this run once macro:

Sub UpdateHeadingStyles()
'
' test Macro
' Macro recorded 9/7/2007 by Andrew B
'

CustomizationContext = NormalTemplate
Dim i As Integer
Dim keyCode As Integer

keyCode = 48
' 48 is the numeric value of the constant vbKey0. We will add one to this on each loop to get the appropriate key.

For i = 1 To 5
keyCode = keyCode + 1
KeyBindings.Add keyCode:=BuildKeyCode(keyCode, wdKeyControl, wdKeyShift), KeyCategory:=wdKeyCategoryMacro, Command:="StyleToHeading" & i
Next i
End Sub

0 Comments:

Post a Comment

<< Home