如何以编程方式获取 PowerPoint 文件格式
我需要确定 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当演示文稿打开时,没有文件格式,所有文件都在内存中。但是,它来自的文件可以位于较旧的 二进制格式或较新的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.
不幸的是,没有文件格式属性。您必须走扩展路线,例如:
There is no File Format property, unfortunately. You'll have to go the extention route, like: