Created
July 16, 2017 19:41
-
-
Save nitram2342/7356aab478987d03a463da44d6261dfd to your computer and use it in GitHub Desktop.
Update VBA code in Word templates programatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Helper script to extract a VBA code blob from a Microsoft Word template | |
# and update the VBA code blobs in other Word templates. | |
# | |
# Author: Martin Schobert <martin@weltregierung.de> | |
# | |
SRC=$1 | |
DST=$2 | |
# check if files exists | |
if [ ! -f $SRC ] ; then | |
echo file "$SRC" does not exist | |
exit | |
fi | |
if [ ! -f $DST ] ; then | |
echo file "$DST" does not exist | |
exit | |
fi | |
# extract vba code from source archive | |
unzip -j $SRC word/vbaProject.bin -d . | |
# delete vba code in destination archive | |
zip -d $DST word/vbaProject.bin | |
# add new vba code to destination archive | |
zip $DST vbaProject.bin | |
# rename file, respectivley change the path | |
printf "@ vbaProject.bin\n@=word/vbaProject.bin" | zipnote -w $DST | |
# show archive content | |
unzip -l $DST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment