如何在 PowerPoint VBA 中模拟 ThisPresentation [英] How to simulate ThisPresentation in PowerPoint VBA

查看:51
本文介绍了如何在 PowerPoint VBA 中模拟 ThisPresentation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够通过加载项本身的一些 VBA 代码访问 PowerPoint 加载项文件(保存为PowerPoint 加载项 (*.ppa)"的演示文稿)的文档属性.

I would like to be able to access the document properties of a PowerPoint add-in file (a presentation saved as "PowerPoint Add-in (*.ppa)", from some VBA code in the add-in itself.

如果这有助于理解问题,我实际要做的是读取存储加载项版本号的自定义文档属性,以便我可以在对话框中显示该属性.

If it helps to understand the problem, what I'm actually trying to do is read a custom document property that stores the version number of the add-in, so that I can display that in a dialog box.

使用 Word &Excel 我可以使用 ThisDocument &ThisWorkbook,两者都返回对包含运行代码的文档的引用.但是,PowerPoint 中没有等效的 ThisPresentation.

With Word & Excel I can do this using ThisDocument & ThisWorkbook, both of which return a reference to the document containing the running code. However, there is no ThisPresentation equivalent in PowerPoint.

对于标准的 PowerPoint 演示文稿或模板,我可以使用 ActivePresentation.但是,此方法不适用于加载项.

For a standard PowerPoint presentation or template, I could use ActivePresentation. However, this method won't work for an add-in.

有什么想法吗?拜托,没有关于我应该在哪里粘贴版本号的建议:-)

Any ideas? Please, no suggestions about where else I should stick the version number :-)

推荐答案

REVISED FEB 2, 2010:清理答案以仅显示最终解决方案

这是按照要求执行的方法,没有 DLL.真的很简单:

Here's the way to do what was asked, no DLLs. Really simple:

Sub ReturnPPAasPresentation()
    Dim p As Presentation
    Set p = Presentations("presentation1.ppa")
    Dim title As String, version As String
    version = p.CustomDocumentProperties("Version").Value
    title = p.BuiltInDocumentProperties("Title").Value
    MsgBox "Version: " & version & " of " & title, vbOKOnly, title
End Sub

这篇关于如何在 PowerPoint VBA 中模拟 ThisPresentation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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