【发布时间】:2016-10-03 09:19:11
【问题描述】:
我有一些代码循环通过数据验证列表并将页面打印为 PDF 文件,我不知道如何调整它以将页面发送到打印机而不是打印为 PDF。
Sub Button11_Click()
Application.ScreenUpdating = False
Dim cell As Range
Dim rgDV As Range
Dim DV_Cell As Range
Dim ws As Worksheet
Dim strPath As String
Dim myFile As Variant
Dim strFile As String
Dim LA As Boolean
Dim A As Integer
Dim B As Integer
Set DV_Cell = Range("B1")
Set rgDV = Application.Range(Mid$(DV_Cell.Validation.Formula1, 2))
A = Application.InputBox("Enter Page From")
B = Application.InputBox("Enter Page To")
Set ws = ActiveSheet
For Each cell In rgDV.Cells
DV_Cell.Value = cell.Value
strFile = Cells.Range("B1") & " Period " & Cells.Range("J1")
strFile = Cells(5, 17).Value & "\" & strFile & ".PDF"
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False, _
From:=A, _
To:=B
Next
Application.ScreenUpdating = True
Application.ScreenUpdating = True
End Sub
任何关于如何做到这一点的建议将不胜感激。
【问题讨论】:
-
谢谢,已经测试了下面的内容,效果很好。