如何向 PowerPoint 2010 添加调用宏的选项卡

发布于 2024-09-26 09:23:57 字数 253 浏览 0 评论 0原文

我创建了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ低調成傷 2024-10-03 09:23:57

您是否手动创建带有按钮的功能区?我使用自定义 UI 编辑器工具,它的工作方式就像一个魅力。

  1. 只需在 .pptm 中创建任何宏,如下所示:

    Sub SayHello(ByVal 控件作为 IRibbonControl)
        消息框“你好”
    结束子
    

    (ByVal control As IRibbonControl) 部分很重要。

  2. 然后保存并关闭您的 .pptm。

  3. 打开自定义 UI 编辑器工具。在该工具中,单击文件菜单中的打开,导航到 .pptm 并将其打开。

  4. 插入菜单上,单击Office 2010 自定义 UI 部件。这将创建一个新的 XML 文档,该文档将插入到您的 .pptm 中。

  5. 然后,您可以使用示例片段开始创建功能区,但最简单的方法是从插入|示例 XML 菜单,只需单击自定义选项卡。这将插入:

    
        <功能区startFromScratch =“假”>
            <选项卡>
                
                    
                        

    如果在 onAction 之后看到 Callback,请将其替换为宏的名称。在上面的示例中,它是 SayHello,因此它现在应该类似于 onAction="SayHello"

  6. 单击保存,然后关闭自定义 UI 编辑器工具。

  7. 在 PowerPoint 中打开 .pptm 并测试是否已创建名为自定义选项卡的选项卡。导航到它并单击笑脸按钮。您现在应该会看到一个消息框。

  8. 点击文件进入后台,点击另存为...,然后选择文件类型 PowerPoint Add-in (*.ppam) 并保存它在任何位置。记下位置。

  9. 转到文件 |选项|加载项,然后从对话框底部的管理下拉列表中选择PowerPoint 加载项。然后点击开始。单击“**添加新...*”并从保存的位置添加您的加载项。

  10. 关闭 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.

  1. Just create any macro in your .pptm, like this:

    Sub SayHello(ByVal control As IRibbonControl)
        MsgBox "hello"
    End Sub
    

    The (ByVal control As IRibbonControl) part is important.

  2. Then save and close your .pptm.

  3. Open the Custom UI Editor Tool. From that tool, click Open from the File menu and navigate to your .pptm and open it.

  4. On the Insert menu, click Office 2010 Custom UI Part. This will create a new XML document that will be inserted into your .pptm.

  5. 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:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
        <ribbon startFromScratch="false">
            <tabs>
                <tab id="customTab" label="Custom Tab">
                    <group id="customGroup" label="Custom Group">
                        <button id="customButton" label="Custom Button" imageMso="HappyFace" size="large" onAction="Callback" />
                    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>
    

    Where you see Callback in after onAction, replace it with the name of your macro. In our example above, it is SayHello, so it should now look like onAction="SayHello".

  6. Click Save and then close the Custom UI Editor Tool.

  7. 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.

  8. 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.

  9. 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.

  10. 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文