Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secure VBA Excel Addin Code

I have an Excel addin, developed in VBA, deployed on the network.

The addin reads from an Oracle database, and pastes tables in a new worksheet, which will also contain a button (triangle shape) to refresh the table.

Everything works great, but I must protect code with password.

When i do, the following error appears on some machines:

Compile error in hidden module: Main. This error commonly occurs when code is incompatible with the version, platform, or architecture of this application.

Although it compiles perfectly when unlocked.

On other machines it requires VBA password on close, even though i have nothing of the sort defined under close event.

I am hoping to secure my code, without running into above problems. Any suggestions are appreciated.

like image 735
Kelaref Avatar asked Mar 29 '17 10:03

Kelaref


1 Answers

I know of two situations in which this error occurs:

1: 32bit vs. 64bit issues (already mentioned in the comments). If you've developed a 32bit addin and try to deploy/use it within a 64bit Excel, then your quoted error message will appear.

2: Missing references.

I think the second option is more likely to be the cause of the problem, because usually all client PCs in a company will have the identical version of MS Office installed and this error occurs only on some machines.

So I suggest to check your references. In the VBA-Editor (Alt+F11) go to tools --> references and note down any ticked modules. Then compare this to a client where the error is occuring (go to client PC and repeat the procedure).

If the ticked modules don't match between development and client PC, this is most likely the cause of this issue. You might also encounter modules with a "MISSING" written in front of their name on the client PC. In this case, remove the tick from the missing module and try to execute your addin.

If it works flawlessly you should be good to go, if not you'll have to manually install the missing modules on the clients PC.

Hope this will help you.

like image 72
daZza Avatar answered Oct 08 '22 23:10

daZza