VBA to print to PDF based on drop-down using ExportAsFixedFormat has quality issues... fixes?

MikeDolanFliss

New Member
Joined
Jan 20, 2016
Messages
1
Hi there, big and longtime fan.

I've got a project where I'm printing dashboard reports for every county in a state. I'd like to dump PDFs for every element in the dropdown - and that dropdown controls dozens of graphs and text in about 10 pages of reports (in the below example I'm just printing page 4 of the report). I've seen a number of elegant solutions using ExportAsFixedFormat. Unfortunately, the quality of that PDF report (images, colored text, etc.) is noticable..janky. The Adobe PDF printer does a much better job... but I can't seem to get the printout command to print anything recognizable as PDF (though I can get files outputed, I couldn't tell you what format they are.

The issues seems to be with camera tool and images, at least. Attached is a side-by-side of what I'm talking about.

excelprintPDFexample.png

https://www.dropbox.com/s/ymwfmje4lk5gj8q/excelprintPDFexample.png?dl=0

Any thoughts, Excel genuiuses? :)


Sub Macro1()
'
' Macro1 Macro
'
Dim ws As Worksheet
Dim ws_unique As Worksheet
Dim UniqueRng As Range
Dim Cell As Range
Dim DropDown As Range

Application.ScreenUpdating = False

'added so it works across workbooks from a pure "printer" workbook.
Windows("CountyHealthData.xlsx").Activate
'Currently unused...
'DirectoryLocation = ActiveWorkbook.Path

Set ws = Worksheets("Reports") 'Amend to reflect the sheet you wish to work with
Set ws_unique = Worksheets("CT plans") 'Amend to reflect the sheet you wish to work with
Set DropDown = ws.Range("B25")

With ws
Set UniqueRng = ws_unique.Range("F3:F5") 'to F38
For Each Cell In UniqueRng
DropDown.Value = Cell.Value
Name = "E:\Dropbox\Community\CounterTools-Mike Collab\draft reports\" & "DashboardDraft8_" & Cell.Value & ".PDF"
'ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Name _
' , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
' :=False, OpenAfterPublish:=False, From:=4, To:=4

' Prints files, but unrecognizable as PDFs. "Can't open because it's been damaged..." error.
ws.PrintOut IgnorePrintAreas:=False, _
From:=4, To:=4, _
ActivePrinter:="Adobe PDF:", _
PrintToFile:=True, PrToFileName:=Name
Next Cell
End With

Application.ScreenUpdating = True
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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