Accord开发者_开发技巧ing to the notes on office .dotm files, they are similar (or the same) in structure to the .docx files - in other words a zip archive.
If I extract the contents of a .dotm file (using an archiving tool), and then recompress the resulting files back into a .dotm file, preserving the structure (file locations) exactly - MSWord2007 complains that the new .dotm file is invalid.
What additional formatting (in detail) for .dotm files is required that the archiving tool does not (by default) or cannot provide?
Used a tool called 'Infozip' - which consisted of several executables (zip.exe, unzip.exe, etc) to implement a working solution.
[-] Extracted the contents of the .dotm file to a temporary folder using unzip.exe [-] Made the required changes to relevant files (in this case CustumUI.xml) [-] Updated the original archive (.dotm file) by instructing zip.exe to 'refresh' the archive - i.e. NOT recompress to a new archive, but update changed files only.
This seemed to keep the non-standard archive metadata intact while changing the contents of the desired file within the archive. MS Word 2007 now opens the macro-enabled template files and applies the changes correctly.
精彩评论