PDA

View Full Version : Winword.exe Generated Error on Save



Belch
11-17-2005, 04:01 AM
This might be a bit of a general problem but I thought I'd try asking on here...

I have a Word template with an image in the header/footer (as a background image) with a table on the page (covering most of the page). There is also quite a bit of VBA code as a module in the template.

The problem I am having is one I have come across several times - when I edit the template and then go to save it (or quit and save), it crashes with the following error message:


WINWORD.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created. <OK>


If I create a new template and copy the background images, tables and code, it will work fine, but rather than do this each time the error occurs I was wondering if anyone knew of a reason why this keeps cropping up?

My system is running Windows 2000 with Word 2000. It is a 2GHz+ machine so memory, etc is not a problem. Let me know if I need to provide any more info.
Thanks,

Killian
11-17-2005, 08:38 AM
Hi and welcome to VBAX :hi:

Presumably if you create a new template and copy everything across, the issue re-occurs at some stage?
I would imagine either one of the images contains some kind of corruption or (perhaps more likely) there is something in the code causing a memory issue (it doesn't matter how much memory you have if you've got a leak/conflict)

You could rule out the pictures by creating a version of the template without them (or some temp replacements if the code references them) and seeing if that's stable.

In terms of the code, first add "Option Explicit" to the top of each module (if it isn't already there, it should be) the run "Compile Project" from the VBE, Debug menu.
This will show up any undeclared objects/variables

If that goes OK, I'd start looking at what happens in the document_close event (and Auto_Close/Exit if they're used)

Make sure you don't have any over templates or AddIns loaded when you test - conflicts are not unheard of

Hope that helps

fumei
11-17-2005, 08:46 AM
Very helpful comments K.

Belch
11-18-2005, 05:18 AM
Thanks for the info Killian.

I've got the Option Explicit bit in the code and use the Compile option so I can rule out the code causing the problem.
I will try creating some without header images and seeing what happens, and will also look at the document_close event (however this error occurs even if I just select Save so I'm guessing this isn't the cause).
Finally I need to use two template add-ins which contain code all the templates call in.

The thing that is confusing me is why it is happening to only a few templates when others work fine.

Thanks again for your input,

Killian
11-18-2005, 07:12 AM
Ah yes, I should have read the question a bit better - it's crashing on save, so you're right, the doc_close stuff won't matter.

When you say "it is happening to only a few templates", do you mean it's happening on some workstations using the same templates, or that you have different templates that use the commons routines in the addins?

Belch
11-18-2005, 08:19 AM
Of all the templates that use the common routines in the addins, most work fine - it is just a handful that crash, and when they do they crash on any workstation, not just mine.
Also they don't crash the first time they are edited, they will work fine for a while but all of a sudden when I do a regular save they crash.

I can't think of anything I am doing differently to these crashing templates which makes it all the more perplexing.
All the templates are stored in a CVS repository at the end of each day but again this applies to the working templates as well, so I don't see how this would affect it...

I might just have to put this error down to Word misbehaving and randomly corrupting the odd template.

fumei
11-18-2005, 11:17 AM
Sounds like some sort of memory leak. Could you post the templates, and any common code modules?

Belch
11-21-2005, 01:15 AM
Unfortunately I can't as the templates and code are all for work and they won't let me post any of it on here. There are also a large number of templates.

I have had a look again on Google, just searching for the error wording, and there are instances of the same error appearing when Word is started, which is all to do with corrupt template addins - however there was nothing about the error appearing when saving or closing the template, plus I don't think it is the addins that are corrupt as 99% of templates work fine with them.

Anyway I have copied the header/footer images and tables from the corrupt template to a new one and it works fine now - I will just have to do that in future if it occurs again.