打开Powerpoint演示文稿时如何自动执行宏? [英] How to auto execute a macro when opening a Powerpoint presentation?

查看:932
本文介绍了打开Powerpoint演示文稿时如何自动执行宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很基本的问题,但是在Internet上找不到答案.
在Powerpoint 2010中,我有一个宏,每次打开Powerpoint文档时都希望执行该宏.如何实现呢?

谢谢!

I have a pretty basic question, but could not find the answer on internet.
In Powerpoint 2010, I have a macro that I would like to be executed everytime the Powerpoint document is opened. How to achieve this ?

Thanks !

推荐答案

虽然Auto_Open不在PowerPoint演示文稿中运行,但是您可以伪造它.在演示文稿中添加一个CustomUI部件,然后在演示文稿打开时使用CustomUI OnLoad回调运行代码. CustomUI部分只需要CustomUI标签即可.

While Auto_Open doesn't run in a PowerPoint presentation, you can fake it. Add a CustomUI part to the presentation, then use the CustomUI OnLoad callback to run code when the presentation opens. The CustomUI part needs no more than just the CustomUI tags.

从此处获取自定义UI编辑器: http://openxmldeveloper.org/articles/customuieditor.aspx

Get the Custom UI Editor from here: http://openxmldeveloper.org/articles/customuieditor.aspx

在自定义UI编辑器"中打开演示文稿.从插入"菜单插入CustomUI部件:

Open the presentation in the Custom UI Editor. Insert a CustomUI part from the Insert menu:

现在输入一些简单的RibbonX代码,如下所示:

Now enter some simple RibbonX code, like this:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
onLoad="MyOnloadProcedure" >
</customUI>

现在编写打开过程:

Sub MyOnloadProcedure()
    MsgBox "Hello"    
End Sub

如果在外接程序中同时包含此过程和Auto_Open过程,则将首先运行Auto_Open.​​

If you have both this and the Auto_Open procedure in an add-in, Auto_Open runs first.

全面披露:尽管我考虑使用此方法并已在Excel中使用它,但我一直等到我第一次在PPT Alchemy网站上遇到它:

Full disclosure: while I thought of using this approach and have used it in Excel, I waited until I first encountered it on the PPT Alchemy web site: Run Code When PowerPoint Opens.

这篇关于打开Powerpoint演示文稿时如何自动执行宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆