我想做一个对打印进行控制的程序,通过程序往指定活动文档写宏代码,可却不执行(尤其是当点击打印按钮时FilePrint和FilePrintDefault更本就没执行),请斑竹看看:
Private Sub SetDocumentPrint()
On Error Resume Next
Err.Clear
With ActiveDocument
If .Variables("printcopie").Value <> "" Then
If Err.Number = 0 Then
If .Variables("printcopie").Value <> .Variables("hadcopie").Value Then
Err.Clear
.PrintOut Copies:=1
If Err.Number = 0 Then
.Variables("hadcopie").Value = .Variables("hadcopie").Value + 1
MsgBox .Variables("hadcopie").Value
.Save
Else
MsgBox Err.Description
End If
Else
MsgBox "已达到 " & .Variables("hadcopie").Value & " 份的打印上限"
End If
Else
Err.Clear
.PrintOut True
If Err.Number <> 0 Then MsgBox Err.Description
End If
Else
Err.Clear
.PrintOut True
If Err.Number <> 0 Then MsgBox Err.Description
End If
End With
End Sub
Private Sub FilePrint()
Call SetDocumentPrint
End Sub
Private Sub FilePrintDefault()
Call SetDocumentPrint
End Sub |