开发者

C# Interop Excel Macro With Password - Is It Possible?

开发者 https://www.devze.com 2022-12-12 15:19 出处:网络
Does anyone know if it is possible to run a macro embedded inside a workbook which has a password enabled?

Does anyone know if it is possible to run a macro embedded inside a workbook which has a password enabled?

Basically I am able to run a macro in a workbook already - However in my manager 开发者_JS百科wants a freaking password added and I don't think thats possible

Has anyone managed to get this in place?


Are you trying to open the workbook in code and then run the macro?

The open method on the workbook object accepts a password as a parameter.


As mentioned, the Open method can be passed a password. However it's worth noting that hard-coded passwords are pretty trivial to extract from an exe. IMHO it's better to just catch the exception to the open method, prompt the user for the password, and then retry the open method with the provided password.

0

精彩评论

暂无评论...
验证码 换一张
取 消