Hi All,
I need help to tweak a VBA code that I have to enable me to print a defined Print Area of a Sheet.
Here is the Print Code that I already have:
Sub RoundedRectangle21_Click()
'==================
' PRINT Document
'==================
Dim ans As Variant
ans = MsgBox("Do You Wish To Print This Document?", vbYesNoCancel, "Print and Save Document")
If ans = vbNo Then
Exit Sub
ElseIf ans = vbCancel Then ' Don't Print & Save. Revert back to Document
Exit Sub
ElseIf ans = vbYes Then ' Print and Save file
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End If
However, it does not print my defined Print Area which is "F13:M40". I need help to incorpirate this Print Area into the code, please.
I found a little print code which I incorporated into it - by removing the last two lines above, and adding the bolded lines, as shown follows:
Sub RoundedRectangle21_Click()
'==================
' PRINT Document
'==================
Dim ans As Variant
ans = MsgBox("Do You Wish To Print This Document?", vbYesNoCancel, "Print and Save Document")
If ans = vbNo Then
Exit Sub
ElseIf ans = vbCancel Then ' Don't Print & Save. Revert back to Document
Exit Sub
ElseIf ans = vbYes Then ' Print and Save file
With Worksheets("Data")
.PageSetup.PrintArea = "F13:M40"
.PrintOut
End With
End If
With my limited VBA knowledge, I believe that I did something very incorrect there. Hence, when I run it, I get a Runtime Error 9. Please, kindly help.
I also wish to use the PRINT command button specifically for the work book. I do not wish a user to print any other sheet within the workbook. Please, I also need help to disable the Excel 'Print' feature for the workbook (if it is possible), so that only the above Print Command would be active.
Thank you for your anticipated help.
Newqueen
Bookmarks