(Word2003/VBA) New solution for corrupt templates

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

(Word2003/VBA) New solution for corrupt templates

Post by ChrisGreaves »

See also this thread
I am a great fan of Rob Bovey's CodeCleaner, but today it failed to resolve the usual problem: I issue a file-save on my Word2003/VBA project and MSWord chews up CPU cycles and then starts wolfing down mega-bytes of disk space. Task Scheduler, End task, reboot, reload MSWord etc etc.
I tried three times running CodeCleaner and still could not save the template.
Very odd/annoying.

Then I decided to
(1) Open the corrupt template after a re-boot
(2) Create a new template via File, New, Template
(3) Set the required Tools, References
(4) Drag-and-drop each module from the corrupt template into the new template
(5) Check (Debug, Compile) that all is correct
(6) Save, Close the new template, reload MSWord and now everything is tickety-boo.

I don’t know why I didn’t think of this sooner. This method is faster than manually importing the exported modules after running Code Cleaner.
The downside is that I must re-create my toolbar menus, but this got me back on my feet in five minutes after an hour of rinse&repeat.

Cheers
Chris
Last edited by ChrisGreaves on 09 Jul 2022, 11:54, edited 1 time in total.
An expensive day out: Wallet and Grimace

User avatar
Guessed
2StarLounger
Posts: 102
Joined: 04 Feb 2010, 22:44
Location: Melbourne Australia

Re: (Wortd2003/VBA) New solution for corrupt templates

Post by Guessed »

Losing the toolbar menus sounds unpalatable. If you were using dotm files I would have suggested doing a SaveAs to dotx to strip the code quickly but retain the toolbars. Perhaps making a copy of the dot file and removing all modules and userforms, saving/closing is enough to remove your corruption. You can then drag all the modules across from your problem file.

If it works, it also retains styles, content, autotext, keyboard shortcuts etc which would be a pain to recreate if you didn't have to.
Andrew Lockton
Melbourne Australia

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: (Wortd2003/VBA) New solution for corrupt templates

Post by ChrisGreaves »

Guessed wrote:
16 Sep 2021, 06:15
Losing the toolbar menus sounds unpalatable. ... it also retains styles, content, autotext, keyboard shortcuts etc ...
Hi Guessed, and you are correct. That said, most of the times when a template/document becomes corrupt (for me) it appears to be caused by VBA code corruption; let’s say “Corruption in the VBA project area".

In the past, when I did extensive work on automated document editing and cleanup, the contents of the document seemed to self-corrupt. At the time I was making hundreds of changes as I brought WordPerfect 5.1 DOS documents into line.

Nowadays most of my work consists of editing code modules (“Just one more bug to track down ...”) and corruption appears about as frequently, despite my repeated, sometimes daily, calls to Rob Bovey’s Code Cleaner. For all I know (I don’t measure this), my regular use of Code Cleaner IS reducing corruption events; I just don’t see them as often. But yesterday it seemed that a drag-and-drop recovery technique is the only thing that worked.

Cheers
Chris
An expensive day out: Wallet and Grimace