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

查看:36
本文介绍了以编程方式确定 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 文件的原始数据中.

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 文档查看器

证书信息存储在 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天全站免登陆