Hi all,
I am new to VBA programming. My aim is a macro that will print a specific area in a sheet. Please see the code below. When I press F5 to run VBA gives me a runtime error '1004'. I can't see where the problem might be
Please help.
Sub print_sheet1()
With Worksheets("sheet1").PageSetup
.PrintArea = Range("$A$1:$J$50")
.Orientation = xlPortrait
.LeftMargin = Application.CentimetersToPoints(2)
.TopMargin = Application.CentimetersToPoints(2)
.RightMargin = Application.CentimetersToPoints(1)
.BottomMargin = Application.CentimetersToPoints(1)
.Zoom = False
.FitToPagesTall = 1
.FitToPagesTall = 1
End With
Msg = "Are you sure you want to print Sheet 1?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
Worksheets("sheet1").PrintOut Copies:=1, Preview:=1
End If
End Sub
Also, you all can see I have not figured out how to include my code above in the "window" in this post. Anyone who can direct me in the right direction?
Cheers,
B
Bookmarks