crazydragon84
Board Regular
- Joined
- Feb 19, 2015
- Messages
- 195
Hi,
I have a sheet that has multiple pictures (actually a snapshot using the camera tool from other sheets in the workbook) in a sheet. When I hit F12 and save as PDF, the PDF file looks fine. Now, I do the same thing with the macro and use ExportAsFixedFormat, all the images are stretched in the PDF. I thought maybe this was Printer Setup issue (Excel saves images slightly differently when you select different printers as default printer), so I added Application.ActivePrinter to the code to set the appropriate printer as well. It worked twice, then it went back to stretched image again (after opening another file?). Any idea about what is causing this issue and a workaround? Here is my code:
I have a sheet that has multiple pictures (actually a snapshot using the camera tool from other sheets in the workbook) in a sheet. When I hit F12 and save as PDF, the PDF file looks fine. Now, I do the same thing with the macro and use ExportAsFixedFormat, all the images are stretched in the PDF. I thought maybe this was Printer Setup issue (Excel saves images slightly differently when you select different printers as default printer), so I added Application.ActivePrinter to the code to set the appropriate printer as well. It worked twice, then it went back to stretched image again (after opening another file?). Any idea about what is causing this issue and a workaround? Here is my code:
Code:
Sub Print_to_PDF()
Dim STDPrinter As String
If Sheets("FINAL").Visible = False Then Sheets("FINAL").Visible = True
STDPrinter = Application.ActivePrinter
Application.ActivePrinter = "Printer Name Here"
Sheets("FINAL").ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("abc"), Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Application.ActivePrinter = STDPrinter
End Sub