To batch format your letters, you’ll need to create a VBA macro. You can use the macro indefinitely after you set it up. Three examples include:
Appending Images | Modifying font | Adjusting page properties |
---|---|---|
to a header to a signature |
names sizes colors |
margins |
- To retrieve your letters from Slate, create and run a query, and select Decision Letter Export to Word under Output.
- In Microsoft Word, press Alt+F1 to access the editor.
- Begin by entering the following code:
Sub cleanLetters()
Selection.WholeStory
End Sub
Appending Images to a Header
To append an image to a header, add the following code after Selection.WholeStory and before End Sub:
'Append image to header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Dialogs(wdDialogInsertPicture)
.Name = "http://i.imgur.com/hHCIojS.png" 'This is the URL for the header image
.Execute
End With
Appending Signature Image to a Signature
To append a signature image to a signature line, add the following code after Selection.WholeStory and before End Sub:
'Append signature image to signature
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "The Jacksonville University Admissions Team" ' This is the name we're looking for, and it shouldn't exist in the rest of the letter (e.g., in the body)
Do While .Execute
With Dialogs(wdDialogInsertPicture)
.Name = "http://i.imgur.com/x7YxZjv.png" 'This is the URL for the signature
.Execute
End With
Loop
.Text = "admissions@ju.edu" ' Because we replaced the name with the signature, we need to find the unique text that immediately proceeded the name
.Replacement.Text = "Alexander Hamilton^padmissions@ju.edu" ' In this case, we're replacing the email address with "Alexander Hamilton" and then adding the email address to the next line
.Forward = True
.Wrap = wdFindContinue
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
To change font name, font size, or font color, add the following code after Selection.WholeStory and before End Sub:
'Modify font & font size
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.Font.Color = wdColorAutomatic
To change page properties (such as margins), add the following code after Selection.WholeStory and before End Sub:
'Modify margins by inches
With ActiveDocument.PageSetup
.TopMargin = InchesToPoints(2)
.BottomMargin = InchesToPoints(0.75)
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
.HeaderDistance = InchesToPoints(1) 'Distance between the header and top of the page
.FooterDistance = InchesToPoints(1) 'Distance between the footer and bottom of the page
.PageWidth = InchesToPoints(8.5) 'Paper width
.PageHeight = InchesToPoints(11) 'Paper height
End With
- Save the macro by selecting File > Export File.
- Right-click Modules under Normal and select Import File. Select your macro file.
- To run your macro, select the icon.
Tip
A test letter (Test Letter.docx) and a macro file (Test Macro.bas) are attached for your experimentation and use.
Comments
Please sign in to leave a comment.