当前位置:编程学习 > VB >>

求,一个连续打印的VBA

求,一个连续打印的VBA
--------------------编程问答--------------------
录制宏 --------------------编程问答--------------------
引用 1 楼 veron_04 的回复:
录制宏
+
我刚好写过一个,简单的(参数:页码范围,打印份数,打印文件名)
Function PrintOutWord(ByVal PrintType As String, ByVal CopyNum As Byte, ByVal patName As String) As Boolean
    Dim PageNum As String
    On Error GoTo 10
    Set WdApp = New Word.Application
    WdApp.Documents.Open FileName:=patName, _
        ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
        WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
        wdOpenFormatAuto, XMLTransform:=""
    WdApp.Visible = False
    If PrintType = "全部" Then
        WdApp.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
            wdPrintDocumentContent, Copies:=Format(CopyNum), Pages:="", PageType:=wdPrintAllPages, _
            ManualDuplexPrint:=False, Collate:=False, Background:=True, PrintToFile:= _
            False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
            PrintZoomPaperHeight:=0
    Else
        Do While InStr(PrintType, ",") <> 0
            PrintType = Replace(PrintType, ",", ",")
        Loop
        WdApp.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
            wdPrintDocumentContent, Copies:=Format(CopyNum), Pages:=PrintType, PageType:=wdPrintAllPages, _
            ManualDuplexPrint:=False, Collate:=False, Background:=True, PrintToFile:= _
            False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
            PrintZoomPaperHeight:=0
    End If
    WdApp.ActiveWindow.Close
    PrintOutWord = True
    Set WdApp = Nothing
    Exit Function
10 PrintOutWord = False
End Function
--------------------编程问答--------------------
补充:VB ,  VBA
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,