14.05.2022 – Windows/Remove_edit_password_from_VBA.md

Remove edit password from VBA

To remove the (purely cosmetic) password needed to view/edit VBA in .dotm and .xlsm files

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#/bin/bash

# Based on https://stackoverflow.com/a/31073075/6432559

if [[ "$#" -ne 1 ]]; then
        echo "Usage: $0 <file>"
        echo "Works for .dotm and .xlsm"
        exit
fi

if [[ -f word/vbaProject.bin ]]; then
        echo "word/vbaProject.bin already exists, exiting..."
        exit
fi

unzip $1 word/vbaProject.bin

sed s/DPB/DPx/ word/vbaProject.bin > word/vbaProject.bin.tmp

mv word/vbaProject.bin.tmp word/vbaProject.bin

zip $1 word/vbaProject.bin

rm word/vbaProject.bin
rmdir word/