如何向 PowerPoint 2010 添加调用宏的选项卡
我创建了一个 pptm 文件,其中包含打开某些 pptx 模板的宏。然后我创建了一个新选项卡,其中包含用于打开文件的按钮。我将创建的宏附加到这些按钮。只要我的 pptm 文件打开,一切都很好。但在我将其保存为 ppam 文件并将其安装为加载项后,它不再起作用。宏似乎没有出现,按钮仍在尝试通过 pptx 名称引用宏。
有谁知道创建自定义选项卡以启动预定义模板的简单方法?或者像Word一样默认加载宏?或者解决我上面的情况?我看到的唯一替代方案是仅显示在加载项选项卡下的加载项。
I have created a pptm file with macros that open certain pptx templates. I then created a new tab with buttons for opening the files. I attached the macros I created to those buttons. All works great as long at my pptm file is open. But after I save it as a ppam file and install it as an add-in it no longer works. It seems the macros don't come along and the buttons are still trying to reference the macros via the pptx name.
Does anyone know a simple way to create a custom tab to launch predefined templates? Or load macros by default like Word does? Or fix my situation above? The only alternative I see is an add-in that will only show up under the Add-In's tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否手动创建带有按钮的功能区?我使用自定义 UI 编辑器工具,它的工作方式就像一个魅力。
只需在 .pptm 中创建任何宏,如下所示:
(ByVal control As IRibbonControl)
部分很重要。然后保存并关闭您的 .pptm。
打开自定义 UI 编辑器工具。在该工具中,单击文件菜单中的打开,导航到 .pptm 并将其打开。
在插入菜单上,单击Office 2010 自定义 UI 部件。这将创建一个新的 XML 文档,该文档将插入到您的 .pptm 中。
然后,您可以使用示例片段开始创建功能区,但最简单的方法是从插入|示例 XML 菜单,只需单击自定义选项卡。这将插入:
如果在
onAction
之后看到Callback
,请将其替换为宏的名称。在上面的示例中,它是SayHello
,因此它现在应该类似于onAction="SayHello"
。单击保存,然后关闭自定义 UI 编辑器工具。
在 PowerPoint 中打开 .pptm 并测试是否已创建名为自定义选项卡的选项卡。导航到它并单击笑脸按钮。您现在应该会看到一个消息框。
点击文件进入后台,点击另存为...,然后选择文件类型 PowerPoint Add-in (*.ppam) 并保存它在任何位置。记下位置。
转到文件 |选项|加载项,然后从对话框底部的管理下拉列表中选择PowerPoint 加载项。然后点击开始。单击“**添加新...*”并从保存的位置添加您的加载项。
关闭 PowerPoint 并重新打开它。 自定义选项卡功能区应该在那里。单击笑脸图标运行
SayHello
宏。除此之外,您唯一需要做的就是按照您需要的方式以及您希望它们执行的操作自定义宏和功能区控件。查看此链接以获取详细信息:为开发人员自定义 2007 Office Fluent 功能区
Are you manually creating the ribbon with the buttons? I use the Custom UI Editor Tool and it works like a charm.
Just create any macro in your .pptm, like this:
The
(ByVal control As IRibbonControl)
part is important.Then save and close your .pptm.
Open the Custom UI Editor Tool. From that tool, click Open from the File menu and navigate to your .pptm and open it.
On the Insert menu, click Office 2010 Custom UI Part. This will create a new XML document that will be inserted into your .pptm.
You can then use sample snippets to start creating your ribbon, but the simplest is just from the Insert | Sample XML menu, just click on Custom Tab. This will insert:
Where you see
Callback
in afteronAction
, replace it with the name of your macro. In our example above, it isSayHello
, so it should now look likeonAction="SayHello"
.Click Save and then close the Custom UI Editor Tool.
Open your .pptm in PowerPoint and test that a tab called Custom Tab has been created. Navigate to it and click on the happy face button. You should now get a message box.
Go to the Backstage by clicking on File and click Save As... and then choose as the file type PowerPoint Add-in (*.ppam) and save it in any location. Note the location.
Go to File | Options | Add-in and then select PowerPoint Add-ins from the Manage dropdown at the bottom of the dialog. Then click Go. Click **Add New...* and add your add-in from the location you saved it.
Close PowerPoint and reopen it. The Custom Tab ribbon should be there. Click on the happy face icon to run your
SayHello
macro.The only thing you'll need to do beyond this is to customize your macros and ribbon controls they way you need them and for what you want them to do. Check out this link for more info: Customizing the 2007 Office Fluent Ribbon for Developers