我有一个打印宏,它将第一页发送到我们的信头打印机,所有剩余的页面发送到普通纸打印机。然后在普通纸上再次打印该文件以供我们记录。虽然宏在我使用XP和Word 2010时工作,但在最近升级到Windows 7和Office 2013之后,宏有时会崩溃整个Word应用程序。也就是说,如果我运行宏,Word崩溃。如果我单步执行宏,它可以正常工作。这个宏每天都会被多次使用,由于我最近的升级,我不想失去它。
保存宏的任何想法?
下面的宏代码我指定了键盘快捷键 Ctrl + Shift + P
谢谢
Public Sub LetterheadPrint()
' sends page 1 to the letterhead printer (\\scprint04\ASHPLJ5)
' sends page 2 to the regular printer (\\scprint04\ASTaxBill)
' prints another copy on plain paper
On Cancel GoTo Cancelled:
On Error GoTo Cancelled:
' save current printer
Dim sCurrentPrinter As String
sCurrentPrinter = Application.ActivePrinter
' Print Assessee Copy
' page 1 to letterhead printer
Application.ActivePrinter = "\\scprint04\ASHPLJ5"
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="1", To:="1"
' remaining pages to regular printer
Application.ActivePrinter = "\\scprint04\ASTaxBill"
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="2"
' Print Office Copy
ActiveDocument.PrintOut
Cancelled:
'Restore original printer
Application.ActivePrinter = sCurrentPrinter
On Error GoTo 0
End Sub
答案 0 :(得分:0)
Ctrl + Shift + P用于字体大小选择,这可能是问题
Option Explicit
Public Sub LetterheadPrint()
' sends page 1 to the letterhead printer (\\scprint04\ASHPLJ5)
' sends page 2 to the regular printer (\\scprint04\ASTaxBill)
' prints another copy on plain paper
Dim cancel As Integer
Application.ScreenUpdating = False
On cancel GoTo Cancelled:
'On Error GoTo Cancelled:
' save current printer
Dim sCurrentPrinter As String
sCurrentPrinter = Application.ActivePrinter
' Print Assessee Copy
' page 1 to letterhead printer
Application.ActivePrinter = "ASHPLJ5"
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="1", To:="1"
' remaining pages to regular printer
Application.ActivePrinter = "ASTaxBill"
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="2"
' Print Office Copy
ActiveDocument.PrintOut
Cancelled:
'Restore original printer
Application.ActivePrinter = sCurrentPrinter
Application.ScreenUpdating = True
On Error GoTo 0
End Sub
Global.ActivePrinter Property (Word)
在早期版本(如Word 2010)中创建的文档将始终在Word 2013中以兼容模式打开,因此请将其打开并将其另存为新版本
我还建议您安装最新版本的驱动程序和Office更新