-1

It isn't duplicate. Others suggest to crack the password but that's not something we are planning to do. Don't way any legal issues. Macro models are locked. Can't execute programmatically

So we have an excel where we fill some data. Click on the given button. It performs some calculations (using macros probably) and then fill the result in the excel only. We want to take another step forward and want to automate the task to fill the input data too.

The problem is modules are locked i can't programmatically execute macro. enter image description here

Tried executing with python. enter image description here

If we open that file with libre office (linux) it shows this. enter image description here

The excel file is the freely available Fatigue index calculator If its not possible to do it this way. Is there any other way? Can i somehow use the button present in the excel? Any help is appreciated.

I am not an excel guy, correct me if I am wrong somewhere. Can provide more info.

NOTE: I can't (don't want to) break the password due to legality purposes.

targhs
  • 1,477
  • 2
  • 16
  • 29
  • 1
    Are you asking how to [unlock](https://stackoverflow.com/a/27508116/6600940) the VBA project? – Storax Jan 01 '23 at 19:05
  • 1
    Does this answer your question? [Is there a way to crack the password on an Excel VBA Project?](https://stackoverflow.com/questions/1026483/is-there-a-way-to-crack-the-password-on-an-excel-vba-project) – Storax Jan 01 '23 at 19:10
  • 1
    The fact that the project is locked does not mean you are unable to execute the code. It means you are not able to edit it. Make the function/routine public, and you should be able to execute it. Otherwise, you are asking the wrong question. – Dean Jan 01 '23 at 20:56
  • I am sorry if that is confusing. But the last screenshot is from a linux machine. Macro doesn't work there at all but it is somehow able to access the structure. When i try with a windows machine it asks for password. Yes i can execute the code with excel but can't do it programmatically. Please see the first screenshot. It's saying the same thing – targhs Jan 02 '23 at 05:35
  • @Storax let me try that. I am away from my windows machine right now. Will give it a try – targhs Jan 02 '23 at 05:36

2 Answers2

1

If the Workbook itself is locked you can remove the password from the workbook. The steps to do so is listed here.

If that doesn't work try, copying the macro and running it using VBSript

Lastly, as a last resort, you can try using PyAutoGui to automate the process of entering the password in the password field.

Edit: Steps to view or add macro

To view or edit macros, you need to enable the developer tab in excel. Quoting from the Microsoft docs

The DEVELOPER tab, on the ribbon, is where all of the macro commands are.

To have it appear on the ribbon, click FILE > Options > Customize Ribbon, check Developer, and click OK.

To edit the macro:

On the DEVELOPER tab, in the Code group, click Macros.

In the Macro name box, click the macro that you want to edit.

Click Edit. The Visual Basic Editor appears.

Shakir
  • 270
  • 2
  • 11
0

From a previous post from his blog:

For Excel 2007/2010 (.xlsm) files do the following steps:

  1. Create a new .xlsm file.

  2. In the VBA part, set a simple password (for instance 'macro').

  3. Save the file and exit.

  4. Change file extention to '.zip', open it by any archiver program.

  5. Find the file: 'vbaProject.bin' (in 'xl' folder).

  6. Extract it from archive.

  7. Open the file you just extracted with a hex editor.Find and copy the value from parameter DPB (value in quotation mark), example:

  8. DPB="282A84CBA1CBA1345FCCB154E20721DE77F7D2378D0EAC90427A22021A46E9CE6F17188A". (This value generated for 'macro' password. You can use this DPB value to skip steps 1-8)

  9. Do steps 4-7 for file with unknown password (file you want to unlock).

  10. Change DBP value in this file on value that you have copied in step

  11. If copied value is shorter than in encrypted file you should populate missing characters with 0 (zero). If value is longer - that is not a problem (paste it as is).

  12. Save the 'vbaProject.bin' file and exit from hex editor.

  13. Replace existing 'vbaProject.bin' file with modified one.

  14. Change extention from '.zip' back to '.xlsm' Now, open the excel file you need to see the VBA code in.

 The password for the VBA code will simply be macro (as in the
example I'm showing here).
Julia Meshcheryakova
  • 3,162
  • 3
  • 22
  • 42