Excel VBA用户表单打印屏幕另存为pdf [英] Excel VBA UserForm printscreen save as pdf
本文介绍了Excel VBA用户表单打印屏幕另存为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
2)更高的打印屏幕分辨率。是否可以提高打印屏幕的分辨率以获得更高的质量?
我在UserForm上用于按钮的代码:
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))
newWS.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
pdfName = ThisWorkbook.Path & "" & Sheets("MAIN").Range("D14").Value & "Project_Summary" & "_" & " " & Format(Now, "yyyy-mmm-dd") & ".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
推荐答案
Application.PrintCommunication = False
With newWS.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
End With
Application.PrintCommunication = True
ewWS.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfName, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
这篇关于Excel VBA用户表单打印屏幕另存为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文