Reputation: 6668
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.
Upvotes: 1
Views: 386
Reputation: 152501
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.
Upvotes: 2