📜 ⬆️ ⬇️

Forced to bypass password protection of the VBA module in Excel 2010

Hello, friends!
Last days I struggled with such a task:
There is a .xls file with a password protected VBA macro. The file is created by exporting from the program GrandSmet and contains estimates, which must be processed by the macro.
On 32-bit versions - works without problems.

On 64x I encountered the following error:


Microsoft Help gives a clear answer:

')
I contacted Tech. Support, explained the reason. The answer was one:
Everything works for us. Checked on 64 bit versions.


Then I decided to independently edit the macro code . The difficulty encountered - the module is password protected. How to reset / change the password without using specialized password cracking software
So let's get started. I’ll warn you in advance that I’m not a professional programmer, but rather Enikeychik, so incorrect wording is possible, but someone may not like the path I have chosen at all.
First of all, I began to surf the web in search of a solution. Basically full of links to software, from the category PasswordCracker . One of the solutions published on the Ru-Board completely removed the VBA module code.
In the end, my efforts were rewarded - I offer you a free translation of the solution found (unfortunately I can’t point out the source - I don’t remember) + an attempt to understand the essence of the revealed “vulnerability”.

I think that it is no secret to anyone that, starting with Excel 2007, it uses Microsoft Office Open XML as its main format.

FarManager excellently opens the xls file with the display of the entire document structure.
1. Start FarManager.
2. Open the file for editing.
3. We are looking for a string with the definition of the DPB key, and change the key name to DPW.
4. Save.
4. Open the file in Excel.
5. We confirm the loading of the project, despite the incorrect key (which we ourselves have made incorrect in paragraph 3):

6. In the windows with error messages boldly click OK.
7. Using the Alt + F11 combination, we launch the VBA Editor and, voila, the macro code is available for editing.

Now the cause of the error that occurred when launching the macro in the x64 environment is obvious!

The compiler suggests that the code in this project should be updated for use on 64-bit systems, specifically indicating that it was necessary only to add the PtrSafe keyword when declaring the function.

Changes made, re-saved, checked. Everything is working. I was pleased with my colleagues with a solution to the sore problem + gained experience.

I am trying to solve the last question, on which I am stalled:
How intelligibly, and without offending, to explain the Tech. Support about solving the problem with the launch of the macro? I don’t have to self-shovel all the templates (and there are about 50) in order for the macro to work correctly on x64 versions of the Office. In addition, the issue of ethics - had to "bypass" the protection code macro.

Grateful for your attention. I hope that the information was useful for some part of the community.

PS Inspired by the solution of the problem, and left with only one question that I asked a little higher, I decided to create my first topic on Habré, in the hope of professional, friendly advice.

Source: https://habr.com/ru/post/144362/


All Articles