【问题标题】:Print error in Word 2013Word 2013 中的打印错误
【发布时间】:2015-06-03 08:29:35
【问题描述】:

我有一个打印宏,它将第一页发送到我们的信头打印机,并将所有剩余页面发送到普通纸打印机。然后将文件再次打印在普通纸上以供我们记录。虽然宏在我使用 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

【问题讨论】:

  • 胡乱猜测....尝试更改快捷键...Ctrl-Shift-P 用于字体大小,可能会导致问题。
  • 有时我们所拥有的只是一个疯狂的猜测。至少你有一个,而我没有。我删除了键盘快捷键并使用宏窗口中的“运行”按钮运行宏。它仍然使整个应用程序崩溃。感谢您的猜测。

标签: vba ms-word


【解决方案1】:

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 更新

【讨论】:

  • 又一个不错的猜测,但可惜,没有乐趣。我已将原始文档保存在最新版本中。我什至尝试从头开始创建文档以消除任何不兼容的可能性。还是不行。
  • @TCottengim 我正在运行 win7 office10 似乎没有错误。尝试删除On Error GoTo Cancelled:,然后运行宏看看你得到了什么错误。
  • 我厌倦了删除错误陷阱,但它在正常运行时仍然崩溃。逐步通过仍然有效。我想你可能已经解决了这个问题。我正在运行 Win 7 和 Office 2013,所以我认为 Office 可能是这里的问题。仅供参考:XP 和 Office 2010 也可以正常工作。
  • @TCottengim 如果您使用本地服务器打印机,请尝试将Application.ActivePrinter = "\\scprint04\ASTaxBill" 更改为Application.ActivePrinter = "ASTaxBill"
  • 虽然是网络资源,但我还是试过了。再次没有喜悦。令我困扰的是,如果我在调试模式下单步执行,它工作正常。它只会在“正常”运行时崩溃。
猜你喜欢
  • 2014-07-12
  • 1970-01-01
  • 1970-01-01
  • 2015-01-26
  • 1970-01-01
  • 1970-01-01
  • 2015-04-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多