将以下代码存为txt文件,通过ilogic导入外部规则,然后运行规则。主要可以自动识别纸张,并且可实现自动最佳打印模式。不必每次都去人工选择横向及纵向。实现无脑打印。
Dim oDrawDoc1 As Document
oDrawDoc1 = ThisApplication.ActiveDocument
oPrintMgr = oDrawDoc1.PrintManager
' oPrintMgr.Printer = "请填入打印机" '手动设置默认打印机,一般不必填写,特殊情况填写
rozm=oDrawDoc1.ActiveSheet.Size
' oPrintMgr.ColorMode = kPrintDefaultColorMode' 设定为彩色打印
oPrintMgr.AllColorsAsBlack = True '设定为全黑打印
oPrintMgr.NumberOfCopies = 1 '打印份数
If ActiveSheet.Width>ActiveSheet.Height Then
oprintMgr.Orientation = 13570
End If
If ActiveSheet.Width<ActiveSheet.Height Then
oprintMgr.Orientation = 13569
End If
' 自动判断横向及纵向
oPrintMgr.PrintRange = kPrintAllSheets
oPrintMgr.Scalemode = kCustomScale
oPrintMgr.ScaleMode = PrintScaleModeEnum.kPrintBestFitScale '最佳比例
oStringArray = New String(){"A4", "A3", "猜你喜欢","我不想打印了"}
oList = InputListBox("人生若只如初见,何事秋风悲画扇", oStringArray, "A4", "增强打印", "选择打印类型")
If oList="我不想打印了" Then
MessageBox.Show("等闲变却故人心,却道故人心易变!", "ilogic")
End If
If oList="A4" Then
oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA4
oPrintMgr.SubmitPrint
End If
If oList="A3" Then
oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3
oPrintMgr.SubmitPrint
End If
If oList="猜你喜欢" Then
If rozm=9997 Then
oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA4
i=MessageBox.Show("检测到您设定的图框尺寸为 A4,是否打印为A4?", "Title",MessageBoxButtons.OKCancel)
End If
If rozm=9996 Then
oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3
i=MessageBox.Show("检测到您设定的图框尺寸为 A3,是否打印为A3?", "Title",MessageBoxButtons.OKCancel)
End If
If i=1 Then
oPrintMgr.SubmitPrint
End If
End If