Print range to PDF in color

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
174
Office Version
  1. 365
Platform
  1. Windows
I have this code that works perfectly but I need it to be in color, is there a small tweak I can make to print in color?

VBA Code:
Sub Save_as_pdf_W2IncomeCalc()
Application.EnableEvents = True
ActiveSheet.Unprotect Password:="Mortgage1"
Dim PrintRng As Range
Dim pdfile As String
'Setting range to be printed
Set PrintRng = Range("A1:DF58")
sPath = Environ("USERPROFILE") & "\Desktop\"

pdfile = Application.GetSaveAsFilename _
    (InitialFileName:=sPath & Worksheets("W2 Income Calc").Range("P5").Value & " " & Worksheets("W2 Income Calc").Range("P6").Value, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Select Folder and FileName to save")
Filename = pdfile
If Filename = False Then
Exit Sub
Else
PrintRng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Call MsgBox(pdfile & " file has been saved!")
ActiveSheet.Protect Password:="Mortgage1"
End If
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Well, it normally should create color PDF, are you sure that in 'Page Setup' / tab 'Sheet' / section 'Print' / you haven't 'Black and white' checked ? if so uncheck it and try again.
 
Upvote 0
Solution
Well, it normally should create color PDF, are you sure that in 'Page Setup' / tab 'Sheet' / section 'Print' / you haven't 'Black and white' checked ? if so uncheck it and try again.
argh, so simple and I didn't check that, thanks, that fixed it.
 
Upvote 0
Glad I was able to help (y).
If there is a reason for being checked you could disable/re-enable it in your macro adding these lines of code:
VBA Code:
[...]
Else
ActiveSheet.PageSetup.BlackAndWhite = False '<= added
PrintRng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveSheet.PageSetup.BlackAndWhite = True '<= added
[...]
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,790
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top