Print range to PDF in color

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
76
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

rollis13

Active Member
Joined
Jul 30, 2012
Messages
426
Office Version
  1. 2016
Platform
  1. Windows
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.
 
Solution

mecerrato

Board Regular
Joined
Oct 5, 2015
Messages
76
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.
 

rollis13

Active Member
Joined
Jul 30, 2012
Messages
426
Office Version
  1. 2016
Platform
  1. Windows
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
[...]
 

Watch MrExcel Video

Forum statistics

Threads
1,129,932
Messages
5,639,067
Members
417,067
Latest member
rohitbabshet

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
Top