【问题标题】:How to obtain PowerPoint File Format Programmatically如何以编程方式获取 PowerPoint 文件格式
【发布时间】:2011-02-24 08:39:53
【问题描述】:

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

PowerPoint 对象模型中是否有提供此信息的属性?

【问题讨论】:

    标签: vba ms-office powerpoint office-interop


    【解决方案1】:

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

    对于二进制格式,它是一个OLE Compound File,它总是以字节开头:0xD0、0xCF、0x11、0xE0、0xA1、0xB1、0x1A、0xE1。

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

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

    【讨论】:

    • 我发现这个答案比另一个更有用。
    【解决方案2】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-24
      • 2011-04-02
      • 2012-02-20
      • 1970-01-01
      • 2012-07-09
      • 2010-10-03
      • 1970-01-01
      相关资源
      最近更新 更多