Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (33 sloc) 1.31 KB
from shutil import copyfile
from zipfile import ZipFile
import os
def replace_val(s, key, new_val):
start = s.index(f'{key}="')
end = s.index('"', start + 5)
s = s.replace(s[start:end+1], f'{key}="{new_val}"')
return s
metadata = {
'CMG': '82802EAEB4B2B4B2B0B6B0B6',
'DPB': '0406A830A8AFC5AFC5503BB0C5E451A1601C8376D39507149E04DBDE9B2528620BA427CCE0E6',
'GC': '86842AB22EB6B1B7B1B7B1',
f = input('Enter Filename of xlsm file: ')
new_filename = f[:f.index('.xlsm')] + '.zip'
copyfile(f, new_filename)
with ZipFile('', 'w') as new_arc:
with ZipFile(new_filename, 'r') as zip:
for file in zip.namelist():
if file != 'xl/vbaProject.bin':
with, 'w') as new_file:
with, 'r') as old_file:
with'xl/vbaProject.bin', 'w') as new_config:
with'xl/vbaProject.bin') as config:
old_s =
s = old_s.decode('ansi')
for key, val in metadata.items():
s = replace_val(s, key, val)
s = s.encode('ansi')
os.rename('', f'{f[:f.index(".xlsm")]} - Unlocked.xlsm')
You can’t perform that action at this time.