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
- 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:
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
.Name = "http://i.imgur.com/hHCIojS.png" 'This is the URL for the header image
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
.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
.Name = "http://i.imgur.com/x7YxZjv.png" 'This is the URL for the signature
.Text = "firstname.lastname@example.org" ' Because we replaced the name with the signature, we need to find the unique text that immediately proceeded the name
.Replacement.Text = "Alexander Hamiltonemail@example.com" ' 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
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
.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
- 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.
A test letter (Test Letter.docx) and a macro file (Test Macro.bas) are attached for your experimentation and use.