Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2025, 02:22 AM
eduzs eduzs is offline Problem closing document Windows 10 Problem closing document Office 2019
Expert
Problem closing document
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default Problem closing document

I use Word 2019 + Windows 10, any code that closes the document without saving changes causes Word to crash (closes all open documents, reopen asking for safe mode), a simple example:

Code:
Private Sub Document_Open()
MsgBox "Hi"
Set odoc = ActiveDocument
odoc.Paragraphs(1).Range.Text = "Hi"
odoc.Close savechanges:=wdDoNotSaveChanges
End Sub
It started suddenly.


Only occurs when running from automatic procedure (like Document_Open).
Do not occurs when running by keyboard shortcut.
Does not ocurrs in Office 2010.
I have already tried reinstalling and to update Office.

Any ideas?

Thanks.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #2  
Old 05-16-2025, 03:12 AM
gmayor's Avatar
gmayor gmayor is offline Problem closing document Windows 10 Problem closing document Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It certainly doesn't do that here. May I suggest that you reboot the PC (as Word has a bad habit of storing error conditions after a crash) before trying again. is the example code in the document template or the normal template? If the problem persists it seems likely that the template is corrupt. See also What to do when Word crashes.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 05-16-2025, 04:51 AM
eduzs eduzs is offline Problem closing document Windows 10 Problem closing document Office 2019
Expert
Problem closing document
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

This is in "ThisDocument" object.
This is a entire new docm I created just to test.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #4  
Old 05-16-2025, 05:14 AM
Italophile Italophile is online now Problem closing document Windows 11 Problem closing document Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by eduzs View Post
This is in "ThisDocument" object.
This is a entire new docm I created just to test.
All documents are based on, and remain connected to, a template. In this case it is probably your Normal.dotm.

The "ThisDocument" module is present in a template, including Normal.dotm as well as a document, so you haven't really told us where your code is.
Reply With Quote
  #5  
Old 05-16-2025, 03:59 PM
eduzs eduzs is offline Problem closing document Windows 10 Problem closing document Office 2019
Expert
Problem closing document
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Suddenly the problem disappeared.
Thanks all.
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
The <toggleButton.../> of the first document open crashes word when closing the second on Ddadoo57 Word VBA 5 03-23-2023 05:32 AM
How can I re-populate my userform after closing the document? pfigen@gmail.com Word VBA 2 05-05-2022 02:08 AM
Problem closing document Track Changes Automatically Accepting Changes after Closing and Re-Opening Document cnethercott Word 1 01-16-2017 03:21 AM
Closing space between document and vertical ruler ToddPr Word 6 08-28-2014 12:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft