Word 2007 macros

Just updated Word 2007 with the five macros which I assign as:

ALT-1 Heading 1
ALT-2 Heading 2
ALT-3 Heading 3
ALT-N Normal text

I have another macro assigned to a toolbar button to take the current highlighted address, presumably an inside address in a letter, say, and print out an envelope.

The VBA, Visual Basic for Applications code for these macro code is in the archives.

The only change is that the default VBA now requires variables to pre-declared by inserting an Option Explicit in the “declarations” section of the macro code. This requirement affects the envelope macro. and after the first line, I had to declare the string variable using

DIM lkAddress AS String

The full macro code is repeated below.
Using these macros eliminates much of the hunting around that I seem to require in Word 2007. The headers change color and font if you change the document theme.

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.

Dim lkAddress As String

'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

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 )

Facebook photo

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

Connecting to %s