Results 1 to 2 of 2
Thread: Word Macro Errors
2001-03-30, 14:58 #1
- Join Date
- Jan 2001
- Thanked 0 Times in 0 Posts
Word Macro Errors
I'm posting this because I'm curious if anyone else has come across the problem I'm about to describe.
I'm in charge of the templates used by a documentation group of about 20 people. We publish end user manuals for software, so we try to make the manuals as professional looking as possible. The result is that the template we use is very rich in resources including styles, AutoText entries, custom toolbars, and macros.
Ocassionally we'll add or update template features. This usually requires several rounds of fixes (particularly in the case of macros). Often this will cause one of the macros will suddenly start causing an error like the following:
"The instruction at '0x084f8e0c' referenced memory at '0x00003d24'. The memory could not be 'read'." (The addresses are always different.)
This always causes Word to shut down. I solve this problem by doing the following:
* creating a fresh template from scratch
* copying the existing templates resources to the new template using Word's Organizer (Tools > Templates and Add-Ins > Organizer)
* saving the new template using the old template's name.
This procedure usually eliminates the problem. I've noticed that the new template is always smaller than the old, suggesting that Word is not doing an efficient job of saving changes to the macro. The last time I did this the new template was one-third smaller than the old template.
To answer the standard questions, yes I do have "Allow fast saves" turned off. We have also had our network services people make the directory that we use as our workgroup templates directory to be read-only .
As a preventive measure I've made it a standard practice to "recreate" any templates that I have made numerous changes to before releasing them to the world.
I'm fairly satisfied with my solution to this problem. But I'm curious if anyone else has seen this, and if so, have you come the same conclusions I have?
2001-03-30, 22:13 #2
- Join Date
- Jan 2001
- Sun Prairie, Wisconsin, Wisconsin, USA
- Thanked 122 Times in 119 Posts
Re: Word Macro Errors
Code bloat is a well-documented side-effect of extensive editing of macros. Payne Consulting used to have a free add-in utility available called "Code Cleaner" that helped. You can recreate it. What it does is export all modules, delete the modules, save the file, import the modules back into the file. It also had options to strip out comments and spaces.
If you would like, I will email you a copy of this add-in.
If you haven't looked at them already, I would recommend that you take a look at (http://www.mvps.org/word/FAQs/Custom...platePart2.htm) and <A target="_blank" HREF=http://www.mvps.org/word/FAQs/Numbering/WordsNumberingExplained.htm>Word's Numbering Explained (http://www.mvps.org/word/FAQs/Number...gExplained.htm). If you download the first in Word format, it comes with a template for a manual that is built to withstand heavy editing. The second shows how and why Word's numbering scheme leads to corrupt documents (and templates) when automatic numbering is used unless a great deal of care is used.
What follows next is advice that I have given before on moving customizations into a global template, most of which applies to recreating templates and all of which you may already know:
To move your macros (and custom toolbars) to a global template,
The simplest way is to open the template or create a new document based on the template. If you don't already have a global template, go to File => New and click "New Template" in the bottom right corner of the dialog box. Select blank document. You can use this document to keep notes on what you have done if you want. Save it using a name like "MyGlobal.dot." Don't close it.
Use the Organizer:
(Tools => Templates and Add-Ins... => Organizer (button) => Macro Project Items (tab)) to move it.
Probably, the macros will be in the Macro Module "New Macros." in Normal.dot. If you already have a Module named "New Macros" in your template, rename it for now so you can copy the Module from Normal.dot to your template. If there are other modules in Normal.dot you want to copy those as well.
Then close the Organizer and save your template.
Use the VBA Editor (Alt-F11) to look at the New Macros module in your template (not the one in Normal.dot). You should be able to spot the macros that you use. Delete any other macros and Ctrl-S to save your changes to the Template. If you already had macros in your template and had to rename "New Macros," double-click on that module. For now, you will want to move all the macros to your new "New Macros" module. Then right-click on the Module that used to be "New Macros" and remove it. It will ask you if you want to export first; answer: No. With your insertion point back in the New Macros module of your template, press Ctrl-S to again save your template.
Then double click on the Module "New Macros" in Normal.dot and delete the macros that you transferred to your template. Ctrl-S to save your changes to Normal.dot.
If you have toolbars that you want to move, copy those as well, after you have copied any macros that the toolbars call. Styles won't do you much good in a global template. If you need to move those as well, write back and we'll get into it.
Save and close your global template.
Open a new blank document. Tools => Customize => Toolbars (1st Tab) and check your toolbars. Right-click on the selection and rename it xxx Old Toolbar. (We are doing this before deleting it. Want to check if new toolbar works and can't really do that without changing the name.) Close the Customize dialog box.
Create a new document from your template. File => New... Check to see if your toolbars and macros function the way you want them to. Type something in the document and then close it without saving it. You should be prompted as to whether your want to save the changes made to MyGlobal.dot. Answer "Yes."
Assuming that your toolbars and macros function properly, you can now use Tools => Customize (this time customizing Normal.dot) to delete "Anne's Old Toolbar." Quit Word and save your changes to Normal.dot.
Next time, when you create a toolbar using the Customize command under the Tools menu, or Tools = Macros... to record a macro, check to make sure that it is being saved in the template that will be using it rather than in Normal.dot. Likewise, make sure that any changes you make to that toolbar or macro get saved in the template.
This way, if you pass your template on to someone else, they will have the benefit of your toolbar and macros.
You must have hit a hot button for me on this. Whew! <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
See <A target="_blank" HREF=http://www.addbalance.com/usersguide/templates.htm>Template Basics</A> (www.addbalance.com/usersguide/templates.htm) for more on templates (user and workgroup), global templates and Normal.dot.
<img src=/S/yadda.gif border=0 alt=yadda width=15 height=15>
The method of copying multiple times also improves copying of styles. Both for the same reason, that when well-planned, styles and toolbars both build dependencies and "based-on" relationships. These break down during copying because the based-on resource may be copied after the dependant resource.
I hope these ramblings are of some use.Charles Kyle Kenyon