Excel 2010打印预览问题

Last week, you saw my macro for adding worksheet data to the Excel footer, and formatting a date in the Excel footer. In that example, you had to run the macro by going to the View tab, and clicking the Macro command. To make the process easier, I decided to add event code to the workbook, so the macro would run automatically.

上周,您看到了我的宏,用于将工作表数据添加到Excel页脚 ,并在Excel页脚中设置日期格式。 在该示例中,您必须通过运行“视图”选项卡并单击“宏”命令来运行宏。 为了简化此过程,我决定将事件代码添加到工作簿中,以便宏可以自动运行。

In the ideal Excel world, where all the worksheets are filled with unicorns and rainbows, that would be a simple task. But unfortunately, Excel 2010 is missing a rainbow or two. Keep reading, to see the Print Preview problem in Excel 2010, and my workaround.

在理想的Excel世界中,所有工作表都充满了独角兽和彩虹,这将是一个简单的任务。 但不幸的是,Excel 2010缺少一两个彩虹。 继续阅读,以了解Excel 2010中的打印预览问题以及我的解决方法。

创建事件代码 (Create the Event Code)

To automate the footer macro, I wanted to use the Workbook_BeforePrint event. That would update the footer, before printing or previewing. In the sample workbook, the macro to fix the footer is named SetFooter.

为了自动化页脚宏,我想使用Workbook_BeforePrint事件。 这样可以在打印或预览之前更新页脚。 在示例工作簿中,用于修复页脚的宏称为SetFooter。

beforeprintproblem01

So, in the Visual Basic Editor, I opened the ThisWorkbook module, for the footer workbook. From the Object drop down list, I selected Workbook.

因此,在Visual Basic编辑器中,我为页脚工作簿打开了ThisWorkbook模块。 从对象下拉列表中,我选择了工作簿。

beforeprintproblem02
beforeprintproblem03

That creates a Workbook_Open event, but you can ignore or delete that. In the Procedure drop down list, I selected BeforePrint

这将创建一个Workbook_Open事件,但是您可以忽略或删除该事件。 在“程序”下拉列表中,我选择“ BeforePrint”

In the blank row in the BeforePrint procedure, I type the macro name – SetFooter

在BeforePrint过程的空白行中,键入宏名称– SetFooter

beforeprintproblem04

Now, the SetFooter macro should run when I print or preview the workbook.

现在,SetFooter宏应该在我打印或预览工作簿时运行。

在Excel 2010中测试 (Testing in Excel 2010)

With rainbows still overhead, I changed the worksheet data, and clicked the Print Preview and Print icon on my Quick Access Toolbar (QAT).

仍然有彩虹,我更改了工作表数据,然后单击快速访问工具栏(QAT)上的“打印预览和打印”图标。

beforeprintproblem05

Nothing changed! The preview footer still showed the old information, so the SetFooter macro hadn't run.

没有改变! 预览页脚仍显示旧信息,因此SetFooter宏没有运行。

In previous versions of Excel, the same code worked perfectly, when clicking the Preview button. I tested in Excel 2007 and Excel 2003, just to be sure.

在早期版本的Excel中,单击“预览”按钮时,相同的代码可以完美地工作。 可以肯定,我在Excel 2007和Excel 2003中进行了测试。

Excel 2010预览解决方法 (Excel 2010 Preview Workaround)

In previous versions of Excel, the same code worked perfectly, when clicking the Preview button. I tested in Excel 2007 and Excel 2003, just to be sure.

在早期版本的Excel中,单击“预览”按钮时,相同的代码可以完美地工作。 可以肯定,我在Excel 2007和Excel 2003中进行了测试。

What's different in Excel 2010? Now, instead of a Preview window, the workbook switches to the File tab when you click Preview, and shows the Print settings.

Excel 2010有什么不同? 现在,当您单击“预览”时,工作簿将切换到“文件”选项卡,而不是“预览”窗口,并显示“打印”设置。

beforeprintproblem06

After some searching, I found an old Preview command, and added that to the QAT. Here's how to do that:

经过一番搜索,我发现了一个旧的Preview命令,并将其添加到QAT中。 这样做的方法如下:

  1. On the QAT, click the Customize arrow, at the far right.

    在QAT上,单击最右侧的“自定义”箭头。
  2. Click More Commands, to open the Excel Options window.

    单击“更多命令”,以打开“ Excel选项”窗口。
  3. From the Choose Commands From drop down, select Commands Not in the Ribbon

    从“选择命令来源”下拉列表中,选择“功能区中没有的命令”
  4. Scroll down the list, and click on Print Preview Full Screen

    向下滚动列表,然后单击全屏打印预览
  5. Click the Add button, to put the command on the QAT

    单击添加按钮,将命令放在QAT上
  6. Click OK, to close the Excel Options window.

    单击确定,关闭“ Excel选项”窗口。
beforeprintproblem07

Now, you can click the Print Preview Full Screen icon on the QAT, and the BeforePrint event is triggered, to run the SetFooter macro.

现在,您可以单击QAT上的“打印预览全屏”图标,并触发BeforePrint事件,以运行SetFooter宏。

beforeprintproblem08

Be careful though – the Print Preview Full Screen icon looks exactly like the Print Preview and Print icon. ___________

但是请注意–“打印预览全屏”图标看起来与“打印预览”和“打印”图标完全相同。 ___________

翻译自: https://contexturesblog.com/archives/2011/09/28/excel-2010-print-preview-problems/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值