Sub Envelope()
[green]'
' Envelope Macro -- Keystroke shortcut = Alt+E
' Creates 8.5 x 11 inch foldable envelope insert
' with company return address and highlighted text as addressee
'
'Copies highlighted text[/green]
Selection.Copy
[green]'Opens a new blank document and changes the empty paragraph formatting[/green]
Documents.Add DocumentType:=wdNewBlankDocument
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.ParagraphFormat.SpaceAfter = 0
Selection.MoveLeft Unit:=wdCharacter, Count:=1
[green]'Changes document margins[/green]
With ActiveDocument.PageSetup
.TopMargin = InchesToPoints(0.3)
.BottomMargin = InchesToPoints(0.3)
.LeftMargin = InchesToPoints(0.3)
.RightMargin = InchesToPoints(0.3)
End With
[green]'Creates a table[/green]
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
2, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
[green]'Selects table and gets rid of visible borders[/green]
Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
Selection.Move Unit:=wdRow, Count:=1
[green]'Sets table row heights[/green]
ActiveDocument.Tables(1).Rows(1).Height = InchesToPoints(7.13)
ActiveDocument.Tables(1).Rows(2).Height = InchesToPoints(1.25)
ActiveDocument.Tables(1).Rows(3).Height = InchesToPoints(0.18)
ActiveDocument.Tables(1).Rows(4).Height = InchesToPoints(1.61)
[green]'Sets cell formatting[/green]
With ActiveDocument.Tables(1).Rows(2).Cells(1)
.VerticalAlignment = wdCellAlignVerticalCenter
Dim aCell As Cell
Set aCell = ActiveDocument.Tables(1).Cell(2, 1)
aCell.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
[green]'Adds text to cell 2,1[/green]
.Range.Text = "Company Name" & vbCr & "ATTORNEYS AT LAW" & vbCr & "First Line of Address" & vbCr & "NEW YORK, NEW YORK 10038"
[green]'Formats text in cell 2,1[/green]
aCell.Range.Font.Name = "Garamond"
aCell.Range.Font.Size = 10
Dim FirstLine As Paragraph
Set FirstLine = ActiveDocument.Tables(1).Cell(2, 1).Range.Paragraphs(1)
FirstLine.Range.Font.Size = 13
FirstLine.Range.Font.SmallCaps = True
End With
[green]'Sets cell formatting[/green]
With ActiveDocument.Tables(1).Rows(4).Cells(1)
.VerticalAlignment = wdCellAlignVerticalCenter
[green]'More cell formatting and paste special unformatted text from clipboard into cell[/green]
Dim bCell As Cell
Set bCell = ActiveDocument.Tables(1).Cell(4, 1)
bCell.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
bCell.Range.ParagraphFormat.LeftIndent = InchesToPoints(0.25)
bCell.Range.Font.Size = 10
bCell.Range.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
End With
[green]'Creates two fold lines[/green]
ActiveDocument.Shapes.AddConnector(msoConnectorStraight, 1.05, 101.65, _
609.9, 0#).Select
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.ConnectorFormat.Type = msoConnectorStraight
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.Left = 0.7
Selection.ShapeRange.Top = 101.5
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
Selection.ShapeRange.RelativeHorizontalSize = wdRelativeHorizontalSizePage
Selection.ShapeRange.RelativeVerticalSize = wdRelativeVerticalSizePage
Selection.ShapeRange.Left = InchesToPoints(-0.29)
Selection.ShapeRange.LeftRelative = wdShapePositionRelativeNone
Selection.ShapeRange.Top = InchesToPoints(3.05)
Selection.ShapeRange.TopRelative = wdShapePositionRelativeNone
Selection.ShapeRange.WidthRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.HeightRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.LockAnchor = False
Selection.ShapeRange.LayoutInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 4
Selection.ShapeRange.Line.ForeColor.ObjectThemeColor = _
wdThemeColorBackground1
Selection.ShapeRange.Line.ForeColor.TintAndShade = -0.25
Selection.ShapeRange.Line.Visible = msoTrue
ActiveWindow.ActivePane.VerticalPercentScrolled = 24
ActiveDocument.Shapes.AddConnector(msoConnectorStraight, 0.7, 392.8, _
609.9, 0#).Select
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.ConnectorFormat.Type = msoConnectorStraight
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.Left = 0.7
Selection.ShapeRange.Top = 393.1
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
Selection.ShapeRange.RelativeHorizontalSize = wdRelativeHorizontalSizePage
Selection.ShapeRange.RelativeVerticalSize = wdRelativeVerticalSizePage
Selection.ShapeRange.Left = InchesToPoints(-0.29)
Selection.ShapeRange.LeftRelative = wdShapePositionRelativeNone
Selection.ShapeRange.Top = InchesToPoints(6.65)
Selection.ShapeRange.TopRelative = wdShapePositionRelativeNone
Selection.ShapeRange.WidthRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.HeightRelative = wdShapeSizeRelativeNone
Selection.ShapeRange.LockAnchor = False
Selection.ShapeRange.LayoutInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 4
Selection.ShapeRange.Line.ForeColor.ObjectThemeColor = _
wdThemeColorBackground1
Selection.ShapeRange.Line.ForeColor.TintAndShade = -0.25
Selection.ShapeRange.Line.Visible = msoTrue
End Sub