以编程方式确定Excel文件(.xls)是否包含宏 [英] Programmatically Determine If An Excel File (.xls) Contains Macros

查看:265
本文介绍了以编程方式确定Excel文件(.xls)是否包含宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以编程方式确定.xls是否包含宏,而不在Excel中实际打开?

Is there any way to programmatically determine if an .xls contains macros, without actually opening it in Excel?

还有什么方法来检查哪个证书(包括时间戳证书)这些宏是用吗?再次没有使用Excel。

Also are there any methods to examine which certificate (including timestamp cert) these macros are signed with? Again without using Excel.

我想知道如果在存在宏时,是否有任何字符串总是显示在Excel文件的原始数据中。 p>

I'm wondering in particular if there are any strings that always show up in the raw data of an Excel file when macros are present.

推荐答案

是的,您可以打开.xls文件作为复合文档文件,并检查是否包含VBA文件夹和包含VBA代码的流

Yes, you can open the .xls file as a compound document file and check whether is contains a VBA folder and streams containing VBA code.

此CodeProject文章中提供了示例代码:

Sample code is available in this CodeProject article:


另一个OLE Doc Viewer,但带有编辑功能

Another OLE Doc Viewer but with editing facility

证书信息存储在 DocumentSummaryInformation 流中。如果你想从那里读出信息,你应该挖掘出可从Microsoft获得的文件格式规范:

The certificate information is stored in the DocumentSummaryInformation stream. If you want to read out the information from there you should dig into the file format specifications available from Microsoft:


[MS-OSHARED]:Office通用数据类型和对象结构规范

[MS-OFFCRYPTO]:Office文档加密结构规范

这篇关于以编程方式确定Excel文件(.xls)是否包含宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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