如何以编程方式获取 PowerPoint 文件格式

发布于 2024-09-02 22:27:22 字数 118 浏览 10 评论 0原文

我需要确定 ActivePresentation 是 97-2003 还是 2007 格式。我真的不想检查扩展名。

PowerPoint 对象模型中是否有某个属性可以提供此信息?

I need to determine whether the ActivePresentation is 97-2003 or 2007 format. I really won't want to check the extension.

Is there a property somewhere inside the PowerPoint Object Model which gives this info?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

醉梦枕江山 2024-09-09 22:27:23

当演示文稿打开时,没有文件格式,所有文件都在内存中。但是,它来自的文件可以位于较旧的 二进制格式或较新的OpenXML格式。区分差异的最简单方法是查看文件的前几个字节。

对于二进制格式,它是一个始终会启动的 OLE 复合文件字节:0xD0、0xCF、0x11、0xE0、0xA1、0xB1、0x1A、0xE1。

对于较新的格式,它是 ZIP 文件,始终以字节开头:0x50、0x4B、0x03、0x04

查看文件的前几个字节是快速确定文件类型的最佳方法,尽管这需要更多工作。

When the presentation is open there is no file format, its all in memory. However the file it came from can be in either the older binary format or the newer OpenXML format. The easiest way to tell the difference is to look at the first few bytes of the file.

For the binary formats it is an OLE Compound File which will always start with the bytes: 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1.

For the newer formats it is a ZIP file which will always start with the bytes: 0x50, 0x4B, 0x03, 0x04

Looking at the first few bytes of the file is the best way to quickly determine the file type, though it takes more work.

岁吢 2024-09-09 22:27:23

不幸的是,没有文件格式属性。您必须走扩展路线,例如:

Sub APFileFormat()
Dim ap As Presentation
Set ap = ActivePresentation
Length = Len(ap.Name)
Match = InStrRev(StringCheck:=ap.Name, StringMatch:=".")
ExtentionLength = Length - Match
    Select Case ExtentionLength
        Case 4
            FileFormat = "PowerPoint 2007-2010"
        Case 3
            FileFormat = "PowerPoint 97-2003"
        Case Else
            FileFormat = "undetermined"
    End Select
Debug.Print "The file format of the active presentation is " & FileFormat
End Sub

There is no File Format property, unfortunately. You'll have to go the extention route, like:

Sub APFileFormat()
Dim ap As Presentation
Set ap = ActivePresentation
Length = Len(ap.Name)
Match = InStrRev(StringCheck:=ap.Name, StringMatch:=".")
ExtentionLength = Length - Match
    Select Case ExtentionLength
        Case 4
            FileFormat = "PowerPoint 2007-2010"
        Case 3
            FileFormat = "PowerPoint 97-2003"
        Case Else
            FileFormat = "undetermined"
    End Select
Debug.Print "The file format of the active presentation is " & FileFormat
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文