I have a code for copying userform and pasting it to Users desktop as a pdf file. Pdf file is OK, however quality of image inside it is quite bad. Is there any way to increase the quality of image inside pdf file?
Private Sub btnPrintPDF_Click()
'change to your button name
Dim pdfName As String
Dim newWS As Worksheet
Application.DisplayAlerts = False
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents 'Otherwise, all of screen would be pasted as if PrtScn rather than Alt+PrtScn was used for the copy.
Set newWS = ThisWorkbook.Worksheets.Add(After:=Worksheets(Worksheets.Count))
Application.PrintCommunication = False
With newWS.PageSetup
.Orientation = xlPortrait
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
Application.PrintCommunication = True
newWS.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
pdfName = Environ$("USERPROFILE") & "\Desktop\" & ThisWorkbook.Sheets("Other Data").Range("P14").Value & "," & " " & "Summary" & "_" & Format(Now, "dd.mm.yyyy") & ".pdf"
newWS.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=pdfName, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
newWS.Delete
Unload Me
Application.DisplayAlerts = True
ThisWorkbook.Sheets("MAIN").Activate
End Sub