Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2023, 02:31 AM
Ddadoo57 Ddadoo57 is offline how to properly cancel the current process through AutoClose() sub() Windows 11 how to properly cancel the current process through AutoClose() sub() Office 2021
Advanced Beginner
how to properly cancel the current process through AutoClose() sub()
 
Join Date: Feb 2023
Posts: 74
Ddadoo57 is on a distinguished road
Default how to properly cancel the current process through AutoClose() sub()

Hello,

when closing a document (which already exists in the base and which I open by clicking on it), vba passes through the AutoClose() procedure which has no arguments, and not in BeforeClose(Cancel As Boolean) as it does for a newly created document.

The problem I have in this case is that I can't properly cancel the current process, as can be done in BeforeClose(...) with Cancel = True.

Is there a solution to simulate a BeforeClore in an AutoClose without input arguments?

Best Regards,
David
Reply With Quote
  #2  
Old 03-12-2023, 02:38 AM
Ddadoo57 Ddadoo57 is offline how to properly cancel the current process through AutoClose() sub() Windows 11 how to properly cancel the current process through AutoClose() sub() Office 2021
Advanced Beginner
how to properly cancel the current process through AutoClose() sub()
 
Join Date: Feb 2023
Posts: 74
Ddadoo57 is on a distinguished road
Default

For those who are interested, here is a solution to avoid this problem

You just have to put at the beginning of the AutoClose() procedure (procedure without input argument) the following line of code:
ActiveDocument.Saved = True

From there, for word the document is saved. This "replaces" a bit a Cancel=True that we find for example in the procedure BeforeClose(...) of a class or other.

However, you must now manage the closing, saving... of the document yourself, otherwise word closes it without asking anything.

Well, it's not perfect yet, but it gives us something that may help a bit
Reply With Quote
  #3  
Old 03-12-2023, 05:18 AM
Ddadoo57 Ddadoo57 is offline how to properly cancel the current process through AutoClose() sub() Windows 11 how to properly cancel the current process through AutoClose() sub() Office 2021
Advanced Beginner
how to properly cancel the current process through AutoClose() sub()
 
Join Date: Feb 2023
Posts: 74
Ddadoo57 is on a distinguished road
Default

Sorry but the idea proposed before doesn't do all the work because word still takes over at the end, i.e. the process of closing word can't be stopped as it can be done with Cancel = true in BeforeClose(...)

So I still don't have a solution for this :-(
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to properly cancel the current process through AutoClose() sub() How to cancel a selection? johngross Word VBA 1 01-12-2019 10:15 PM
how to properly cancel the current process through AutoClose() sub() How to call current PC date and/or current PC year KIM SOLIS Excel 2 11-04-2011 06:09 PM
how to properly cancel the current process through AutoClose() sub() How to cancel printing?? RDA1959 Word 1 08-28-2011 12:44 AM
how to properly cancel the current process through AutoClose() sub() Auto insert current month's name and current year Styler001 Word 4 01-25-2010 06:40 PM
Problem with AutoClose macro and Word 2003 cholo Word VBA 0 07-08-2009 05:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:51 AM.


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