简体   繁体   中英

C# run excel macro that has a password

I have an excel workbook that contains a macro which contains a password. I have a C# app that calls this excel macro (not my design). I was wondering if there was a away to password protect the excel macro so people cannot see the password but can still be called by my C# app.

The password has to remain in the workbook so I cannot just move it to my C# app, again this is not my design.

Password-protecting a macro does NOT prevent it from being executed , only viewed and edited .

Just go to the Module properties in the VBA editor, click the "protection" tab and add a password.

Note that string constants are not encrypted in the source file, so you may want to obfuscate the password if it's a human-readable password so it's not easily recognizable by looking at the excel file in a text editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM