Simple Word Macros

I’m a simple minded guy. I use Microsoft Word for all of my word-processing. I can get along with about four styles; Heading 1, Heading 2, Heading 3, and Normal. I also like to print single envelopes to my LaserJet printer.

I’ve used macros for these things for years…transferring and updating them to each subsequent version of Word. The following code works in Office 2003:



Sub Heading_1()

'

' Heading_1 Macro

' Macro recorded 6/3/2004 by Lawrence Keyes

' Assigned to Alt_1

Selection.Style = ActiveDocument.Styles("Heading 1")

End Sub

Sub Heading_2()

'

' Heading_2 Macro

' Macro recorded 6/3/2004 by Lawrence Keyes

' Assigned to Alt_2

Selection.Style = ActiveDocument.Styles("Heading 2")

End Sub

Sub Heading_3()

'

' Heading_3 Macro

' Macro recorded 6/3/2004 by Lawrence Keyes

' Assign to Alt_3

Selection.Style = ActiveDocument.Styles("Heading 3")

End Sub

Sub Heading_Normal()

'

' Macro2 Macro

' Macro recorded 6/3/2004 by Lawrence Keyes

'

Selection.Style = ActiveDocument.Styles("Normal")

End Sub

Sub Envelope_Address()

'

' Envelope_Address

' Macro recorded 6/18/2004 by Lawrence Keyes

' Modified 6/18/2004, to hold the selected text

' This macro is assigned to a toolbar button. Select the adress that you want to print

' on the envelope, then click the "Print Envelope" button.

'Assign the currently selected text to the local variable lkAddress

lkAddress = Selection.Text

ActiveDocument.Envelope.PrintOut ExtractAddress:=False, OmitReturnAddress _

:=True, PrintBarCode:=True, PrintFIMA:=False, Height:=InchesToPoints(4.13 _

), Width:=InchesToPoints(9.5), Address:=lkAddress, AutoText:= _

"ToolsCreateLabels3", ReturnAddress:="", ReturnAutoText:= _

"ToolsCreateLabels4", AddressFromLeft:=wdAutoPosition, AddressFromTop:= _

wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _

ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:= _

wdCenterLandscape, DefaultFaceUp:=True, PrintEPostage:=False

End Sub



The above macros are assigned to the keystrokes within the “Customize Keyboard” section of ViewToolBars. Again, it is really simple: ALT-1 is used for Heading 1, ALT-2 for Heading 2, etc. ALT-N is for “normal”. The envelope printing macro is assigned to a button on the toolbar.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s