打开Powerpoint演示文稿时如何自动执行宏?

Lau*_*llo 6 macros powerpoint execute startup

我有一个非常基本的问题,但在互联网上找不到答案.
在Powerpoint 2010中,我有一个宏,我想在每次打开Powerpoint文档时执行它.怎么做到这一点?

谢谢 !

Jon*_*ier 5

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

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

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

添加自定义UI部件

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

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
onLoad="MyOnloadProcedure" >
</customUI>
Run Code Online (Sandbox Code Playgroud)

现在写下你的开放程序:

Sub MyOnloadProcedure()
    MsgBox "Hello"    
End Sub
Run Code Online (Sandbox Code Playgroud)

如果在加载项中同时具有此和Auto_Open过程,则首先运行Auto_Open.

完全披露:虽然我想使用这种方法并在Excel中使用它,但我等到我第一次在PPT Alchemy网站上遇到它:PowerPoint打开时运行代码.