How to automatically prevent printing of shapes on an Excel worksheet with VBA. Watch the video below:
Watch this video on YouTube.
Here’s the complete modified and more efficient VBA code to prevent printing of activex controls, form controls, shapes, pictures and charts automatically:
Private Sub CommandButton1_Click()
If Range(“D2”) = 0 Then
MsgBox “You have 0 quantity in stock!”
Exit Sub
ElseIf Range(“D2”) > 0 Then
Range(“D2”) = Range(“D2”) – 1
Range(“K2”) = Range(“K2”) + 1
End If
End Sub
Sub calculate()
Dim soldqty As Long
Dim ws As Worksheet
Set ws = Worksheets(1)
soldqty = InputBox(“enter the sold quantity”, “Sales”)
If ws.Range(“D2”) = 0 Then
MsgBox “You have 0 quantity in stock!”
Exit Sub
ElseIf ws.Range(“D2”) > 0 Then
ws.Range(“D2”) = ws.Range(“D2”) – soldqty
ws.Range(“K2”) = ws.Range(“K2”) + soldqty
End If
End Sub
Sub donotprintshape()
ActiveSheet.DrawingObjects.PrintObject = False
ActiveSheet.PrintPreview
End Sub