I'm trying to set up a spreadsheet so that it cannot be physically printed, but I have a macro button to save as a PDF which I need to work.
I've used the following codes:
Sub SaveQuoteAsPDF()
Dim fName As String
With Worksheets("Quote")
fName = Range("E21").Value & Format(Now, " ddmmyy")
End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"S:\SALES\Margin Calculator\Quotes\" & fName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Update 20140626
Cancel = True
MsgBox "You can't print this workbook"
End Sub
both work indivually but together the code to disable printing also stops the PDF from being written.
Is there a way to overcome this? I do have another tab that saves as a PDF as well that follows the same code, and as I have looked the workbook this also cannot be written to a PDF. I'm happy to only lock one worksheet, but I struggled to make this work...
Bookmarks