I attached this macro to a command button and it will not run. It worked before I tried placing it onto a button. Please Help!
Below is the macro:
Private Sub CommandButton1_Click()
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.11")
appWD.Visible = True
Sheets("Customer").Select
'Copy the data for the new document to the clipboard
Range("A1:L113").Copy
' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new document
appWD.Selection.Paste
' Setup margins accordingly
appWD.Selection.PageSetup.TopMargin = InchesToPoints(0.22)
appWD.Selection.PageSetup.BottomMargin = InchesToPoints(0.22)
appWD.Selection.PageSetup.LeftMargin = InchesToPoints(0.25)
appWD.Selection.PageSetup.RightMargin = InchesToPoints(0.13)
appWD.ActiveDocument.Shapes("Picture 2").Select
appWD.Selection.ShapeRange.Fill.Visible = msoFalse
appWD.Selection.ShapeRange.Fill.Solid
appWD.Selection.ShapeRange.Fill.Transparency = 0#
appWD.Selection.ShapeRange.Line.Weight = 0.75
appWD.Selection.ShapeRange.Line.DashStyle = msoLineSolid
appWD.Selection.ShapeRange.Line.Style = msoLineSingle
appWD.Selection.ShapeRange.Line.Transparency = 0#
appWD.Selection.ShapeRange.Line.Visible = msoFalse
appWD.Selection.ShapeRange.LockAspectRatio = msoTrue
appWD.Selection.ShapeRange.Rotation = 0#
appWD.Selection.ShapeRange.PictureFormat.Brightness = 0.5
appWD.Selection.ShapeRange.PictureFormat.Contrast = 0.5
appWD.Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
appWD.Selection.ShapeRange.PictureFormat.CropLeft = 0#
appWD.Selection.ShapeRange.PictureFormat.CropRight = 0#
appWD.Selection.ShapeRange.PictureFormat.CropTop = 0#
appWD.Selection.ShapeRange.PictureFormat.CropBottom = 0#
appWD.Selection.ShapeRange.Left = 18#
appWD.Selection.ShapeRange.Top = 72#
appWD.Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
appWD.Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
appWD.Selection.ShapeRange.Left = InchesToPoints(0.4)
appWD.Selection.ShapeRange.Top = InchesToPoints(0)
appWD.Selection.ShapeRange.LockAnchor = False
appWD.Selection.ShapeRange.LayoutInCell = True
appWD.Selection.ShapeRange.WrapFormat.AllowOverlap = False
appWD.Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
appWD.Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.Type = 3
appWD.Selection.ShapeRange.ZOrder 4
appWD.ActiveWindow.ActivePane.VerticalPercentScrolled = 36
appWD.ActiveDocument.Shapes("Picture 3").Select
appWD.Selection.ShapeRange.Fill.Visible = msoFalse
appWD.Selection.ShapeRange.Fill.Solid
appWD.Selection.ShapeRange.Fill.Transparency = 0#
appWD.Selection.ShapeRange.Line.Weight = 0.75
appWD.Selection.ShapeRange.Line.DashStyle = msoLineSolid
appWD.Selection.ShapeRange.Line.Style = msoLineSingle
appWD.Selection.ShapeRange.Line.Transparency = 0#
appWD.Selection.ShapeRange.Line.Visible = msoFalse
appWD.Selection.ShapeRange.LockAspectRatio = msoTrue
appWD.Selection.ShapeRange.Rotation = 0#
appWD.Selection.ShapeRange.PictureFormat.Brightness = 0.5
appWD.Selection.ShapeRange.PictureFormat.Contrast = 0.5
appWD.Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
appWD.Selection.ShapeRange.PictureFormat.CropLeft = 0#
appWD.Selection.ShapeRange.PictureFormat.CropRight = 0#
appWD.Selection.ShapeRange.PictureFormat.CropTop = 0#
appWD.Selection.ShapeRange.PictureFormat.CropBottom = 0#
appWD.Selection.ShapeRange.Left = 18#
appWD.Selection.ShapeRange.Top = 161.25
appWD.Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
appWD.Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
appWD.Selection.ShapeRange.Left = InchesToPoints(0.4)
appWD.Selection.ShapeRange.Top = InchesToPoints(0)
appWD.Selection.ShapeRange.LockAnchor = False
appWD.Selection.ShapeRange.LayoutInCell = True
appWD.Selection.ShapeRange.WrapFormat.AllowOverlap = False
appWD.Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
appWD.Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.Type = 3
appWD.Selection.ShapeRange.ZOrder 4
appWD.Selection.HomeKey Unit:=wdLine
appWD.Selection.InsertBreak Type:=wdPageBreak
appWD.Selection.MoveUp Unit:=wdScreen, Count:=4
End Sub
Below is the macro:
Private Sub CommandButton1_Click()
Dim appWD As Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application.11")
appWD.Visible = True
Sheets("Customer").Select
'Copy the data for the new document to the clipboard
Range("A1:L113").Copy
' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new document
appWD.Selection.Paste
' Setup margins accordingly
appWD.Selection.PageSetup.TopMargin = InchesToPoints(0.22)
appWD.Selection.PageSetup.BottomMargin = InchesToPoints(0.22)
appWD.Selection.PageSetup.LeftMargin = InchesToPoints(0.25)
appWD.Selection.PageSetup.RightMargin = InchesToPoints(0.13)
appWD.ActiveDocument.Shapes("Picture 2").Select
appWD.Selection.ShapeRange.Fill.Visible = msoFalse
appWD.Selection.ShapeRange.Fill.Solid
appWD.Selection.ShapeRange.Fill.Transparency = 0#
appWD.Selection.ShapeRange.Line.Weight = 0.75
appWD.Selection.ShapeRange.Line.DashStyle = msoLineSolid
appWD.Selection.ShapeRange.Line.Style = msoLineSingle
appWD.Selection.ShapeRange.Line.Transparency = 0#
appWD.Selection.ShapeRange.Line.Visible = msoFalse
appWD.Selection.ShapeRange.LockAspectRatio = msoTrue
appWD.Selection.ShapeRange.Rotation = 0#
appWD.Selection.ShapeRange.PictureFormat.Brightness = 0.5
appWD.Selection.ShapeRange.PictureFormat.Contrast = 0.5
appWD.Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
appWD.Selection.ShapeRange.PictureFormat.CropLeft = 0#
appWD.Selection.ShapeRange.PictureFormat.CropRight = 0#
appWD.Selection.ShapeRange.PictureFormat.CropTop = 0#
appWD.Selection.ShapeRange.PictureFormat.CropBottom = 0#
appWD.Selection.ShapeRange.Left = 18#
appWD.Selection.ShapeRange.Top = 72#
appWD.Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
appWD.Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
appWD.Selection.ShapeRange.Left = InchesToPoints(0.4)
appWD.Selection.ShapeRange.Top = InchesToPoints(0)
appWD.Selection.ShapeRange.LockAnchor = False
appWD.Selection.ShapeRange.LayoutInCell = True
appWD.Selection.ShapeRange.WrapFormat.AllowOverlap = False
appWD.Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
appWD.Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.Type = 3
appWD.Selection.ShapeRange.ZOrder 4
appWD.ActiveWindow.ActivePane.VerticalPercentScrolled = 36
appWD.ActiveDocument.Shapes("Picture 3").Select
appWD.Selection.ShapeRange.Fill.Visible = msoFalse
appWD.Selection.ShapeRange.Fill.Solid
appWD.Selection.ShapeRange.Fill.Transparency = 0#
appWD.Selection.ShapeRange.Line.Weight = 0.75
appWD.Selection.ShapeRange.Line.DashStyle = msoLineSolid
appWD.Selection.ShapeRange.Line.Style = msoLineSingle
appWD.Selection.ShapeRange.Line.Transparency = 0#
appWD.Selection.ShapeRange.Line.Visible = msoFalse
appWD.Selection.ShapeRange.LockAspectRatio = msoTrue
appWD.Selection.ShapeRange.Rotation = 0#
appWD.Selection.ShapeRange.PictureFormat.Brightness = 0.5
appWD.Selection.ShapeRange.PictureFormat.Contrast = 0.5
appWD.Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
appWD.Selection.ShapeRange.PictureFormat.CropLeft = 0#
appWD.Selection.ShapeRange.PictureFormat.CropRight = 0#
appWD.Selection.ShapeRange.PictureFormat.CropTop = 0#
appWD.Selection.ShapeRange.PictureFormat.CropBottom = 0#
appWD.Selection.ShapeRange.Left = 18#
appWD.Selection.ShapeRange.Top = 161.25
appWD.Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
appWD.Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
appWD.Selection.ShapeRange.Left = InchesToPoints(0.4)
appWD.Selection.ShapeRange.Top = InchesToPoints(0)
appWD.Selection.ShapeRange.LockAnchor = False
appWD.Selection.ShapeRange.LayoutInCell = True
appWD.Selection.ShapeRange.WrapFormat.AllowOverlap = False
appWD.Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
appWD.Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
appWD.Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
appWD.Selection.ShapeRange.WrapFormat.Type = 3
appWD.Selection.ShapeRange.ZOrder 4
appWD.Selection.HomeKey Unit:=wdLine
appWD.Selection.InsertBreak Type:=wdPageBreak
appWD.Selection.MoveUp Unit:=wdScreen, Count:=4
End Sub