Unlock password protected Workbook using VBA or Python

2024/10/6 6:54:53

I have a workbook name m.xlsx, but it's password protected and I've forgotten the password. How can I open it or un-protect it?

The following code does not work:

  • Unprotect workbook without password
  • I need the command to unprotect an Excel file from python

It ask for password when opened, and the above code does not unlock the workbook.

So, I want to put this code in a new workbook and then link my excel file with a code in place of THISWORKBOOK. Is there a way to put the m.xlsx file path without opening it (as opening of file needs password), and then run this code to unprotect the m.xlsx file?

Or is there any better way to unprotect workbook in VBA or Python programming? I have checked some Python code but they are opening the file and that is where the problem is.

Answer

Since the extension is xlsx it's the Microsoft Excel Open XML Format. That is essentially a .zip file. Try this:

  1. Copy the original file to a new folder so you don't tamper the original
  2. Rename the file to a .zip extension
  3. Extract the content with winzip or the like
  4. In the extracted content, open xl\worksheets\sheet1.xml, preferably as a text file with notepad or the like
  5. Search for <sheetProtection
  6. Remove all from <sheetProtection to and including the terminating />
  7. Save the content as a .zip
  8. Rename to .xlsx

Password gone

https://en.xdnf.cn/q/119981.html

Related Q&A

How do I make a variable detect if it is greater than or less than another one?

I am currently learning Python, and I decided to build a small "Guess the Number" type of game. I am using the random feature, and trying to make it so it will detect if the users input is eq…

Python Regular Expression from File

I want to extract lines following some sequence from a file. E.g. a file contains many lines and I want line in sequencejourney (a,b) from station south chennai to station punjab chandigarh journey (c,…

Changing the words keeping its meaning intact [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

How to create index for a SQLite3 database using SQLAlchemy?

I have multiple SQLite3 databases for which the models are not available. def index_db(name, tempdb):print(f{name.ljust(padding)} Indexing file: {tempdb})if tempdb.endswith(primary.sqlite):conn = sqlit…

Implementing ast.literal_eval on a numpy array

With the following expression, you can convert a string to a python dict.>>> import ast >>> a = ast.literal_eval("{muffin : lolz, foo : kitty}") >>> a {muffin: lolz…

Best way to make argument parser accept absolute number and percentage?

I am trying to write a Nagios style check to use with Nagios. I have working script that takes in something like -w 15 -c 10 and interprets that as "Warning at 15%, Critical at 10%". But I ju…

Python calculating prime numbers

I have to define a function called is_prime that takes a number x as input, then for each number n from 2 to x - 1, test if x is evenly divisible by n. If it is, return False. If none of them are, then…

Why am I getting a column does not exist error when it does exist? I am modifying the Flask tutorial

I have a column named ticker_symbol, but I am getting a error when I run the error that there is no such column. Here is my auth.py code so far. It is similar to the Flask tutorial code. I get my get_d…

Update Key Value In Python In JSON File

How do I change a value in a json file with python? I want to search and find "class": "DepictionScreenshotsView" and replace it with "class": ""JSON File:{&quo…

Getting UnboundLocalError: local variable age referenced before assignment error

Ive written a simple script with TKinter and SQLAlchemy, where an sqlite .db is created, saving Employee information such as name, age, address, etc, etc.I realized that if a user puts a string in the …