I had a very strange problem recently that I thought other people might find entertaining. A global template that we created was causing Word to hang when the user tried to exit. The code worked perfectly on both Word 2003 and Word 2007, but failed on systems that had been upgraded from Word 2003 to 2007.
We couldn't debug this in the normal way as the global template appeared to already be closed at the time of the hang, and commenting out all of our code that runs during document_close didn't make the fault go away.
After much head scratching the only debugging technique that worked was to comment out large chunks of code till the fault went away. It turned out that the problem line was one that set Application.CustomizationContext to the global template. The fix was to add the line
Application.CustomizationContext = NormalTemplate
to the exit routine of any routine that modified any toolbars or menus.
It seemed that Word was trying to access the CustomizationContext after it had closed the document. Since it worked correctly on clean installations there may be an issue with DLLs or some other aspect of installations that have upgraded from Office 2003 to Office 2007.
Word hangs on exit
-
- Administrator
- Posts: 12601
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Word hangs on exit
StuartR
-
- Administrator
- Posts: 78384
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands