Microsoft Office Tutorials and References
In Depth Information
Mail Merge: Making Placecards Using WordArt
Dim rng As Word.Range¶
Dim PlacecardText As String¶
Dim WordArt As Word.Shape¶
Dim IsSecond As Boolean¶
IsSecond = True¶
Set docMain = ActiveDocument¶
Set tmpl = docMain.AttachedTemplate¶
'The merge should be a catalog/directory type¶
If docMain.MailMerge.MainDocumentType <> wdCatalog Then Exit Sub¶
With docMain.MailMerge¶
.Destination = wdSendToNewDocument¶
End With¶
Set docResult = ActiveDocument¶
docResult.AttachedTemplate = tmpl¶
Set tbl = docResult.Tables(1)¶
For Each cel In tbl.Range.Cells¶
'Check whether there is text¶
If Len(cel.Range.Text) > 2 Then¶
Set rng = cel.Range¶
'Get the text for the placecard¶
PlacecardText = TrimCellText(rng.Text)¶
'Then delete it before inserting the WordArt¶
'A shape can't be inserted into the full cell range,¶
'it must be collapsed so that it is only the inside¶
'of the cell¶
rng.Collapse wdCollapseStart¶
'Insert the WordArt, stored as an AutoText¶
tmpl.AutoTextEntries(AutoTextName).Insert Where:=rng,
Set WordArt = rng.Cells(1).Range.ShapeRange(1)¶
'Put in the placecard text¶
WordArt.TextEffect.Text = PlacecardText¶
'Rotate every second one¶
If IsSecond Then¶
WordArt.Rotation = 180¶
End If¶
'Put it into the table cell so that it centers properly¶
If CInt(Val(Application.Version)) = 11 Then¶
ElseIf CInt(Val(Application.Version)) < 10 And
CInt(Val(Application.Version)) > 8 Then¶
WordArt.RelativeHorizontalPosition =
WordArt.Left = ((cel.Width + cel.RightPadding +
cel.LeftPadding) - WordArt.Width) / 2¶
WordArt.RelativeVerticalPosition =
WordArt.Top = (cel.Row.Height - WordArt.Height) / 2¶
Search JabSto ::

Custom Search