Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2023, 03:18 AM
Ddadoo57 Ddadoo57 is offline The <toggleButton.../> of the first document open crashes word when closing the second on Windows 11 The <toggleButton.../> of the first document open crashes word when closing the second on Office 2021
Advanced Beginner
The <toggleButton.../> of the first document open crashes word when closing the second on
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default The <toggleButton.../> of the first document open crashes word when closing the second on

Hello,

I have a custom ribbon, for a dotm word template, and I am having a problem with a series of <toggleButton.../> embedded in a group.

When I create a new document (1) based on my dotm, the series of <toggleButton.../> work fine, but as long as I don't open, on top of this first current document, an old document (2) also based on the same template. When closing this second document, the series of <toggleButton.../> from the first document, no longer works and crashes Word!

Does anyone have any suggestions for me?

Best Regards,


David
Reply With Quote
  #2  
Old 03-14-2023, 03:49 PM
Guessed's Avatar
Guessed Guessed is online now The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Windows 10 The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I would need to do some testing on your template because I don't have much experience with custom toggle buttons in a ribbon.

Perhaps the solution is to create a Class Module and use the WindowActivate event to refresh the ribbon as you change active documents.
See Writing application event procedures for working with Class Modules.

If you can't find a solution with the ribbon refresh suggestion, the bible for all things Ribbon is a book called RibbonX: Customizing the Office 2007 Ribbon by Teresa Hennig, Robert Martin, Ken Puls. It is the next place I would look to see what they have to say about toggleButtons.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-15-2023, 02:04 AM
Ddadoo57 Ddadoo57 is offline The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Windows 11 The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Office 2021
Advanced Beginner
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

Thank you so much Guessed, that's very nice of you!

I'll see if it could be from what you indicate, if not also see if I can't find something in the RibbonX book.

If I have the solution I will indicate it after the post.

Have a nice day,
David

PS: however I have the impression that it comes from the ribbon object, as if the 2, 3... documents opened on the same workstation, shared only one instance instead of having each one its own.
Reply With Quote
  #4  
Old 03-15-2023, 02:27 AM
Ddadoo57 Ddadoo57 is offline The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Windows 11 The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Office 2021
Advanced Beginner
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

... just for the record, I just checked something: the error is only caused when the opened documents have the same basic template (.dotm) used when they were created. If it's not the case, everything works fine. I will ask the user to close the opened document, if the second document he wants to open has the same basic template.
Reply With Quote
  #5  
Old 03-15-2023, 06:05 AM
Italophile Italophile is offline The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Windows 11 The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Office 2021
Expert
 
Join Date: Mar 2022
Posts: 333
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by Guessed View Post
Perhaps the solution is to create a Class Module and use the WindowActivate event to refresh the ribbon as you change active documents.
See Writing application event procedures for working with Class Modules.
Almost correct. It is actually the DocumentChange event that needs to be handled.

If you have a custom ribbon tab that includes toggle buttons, uses GetEnabled or GetVisible callbacks, or supplies document specific functionality then handling the DocumentChange event is imperative.
Reply With Quote
  #6  
Old 03-23-2023, 05:32 AM
Ddadoo57 Ddadoo57 is offline The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Windows 11 The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Office 2021
Advanced Beginner
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

After recoding my button group (only one selected TB at a time), plus adding a variable and managing it to indicate the selected TB of the current document (ActiveDocument.Variables.Add Name:="TBx" & ActiveDocument.Name, Value:="BT1 or....") and activeDocument.Variables("TBx" & ActiveDocument.Name).Value = "BT1 or...", everything seems to be working fine for the open documents.

While waiting to optimize better the code, I use this solution.

Good luck to you and thanks again for your help!
David
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open e-mails closing when moving them to a folder Tomtom Outlook 0 11-14-2019 07:27 AM
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Word crashes if the merged document file is closed first reidtaylor Mail Merge 7 05-07-2019 04:19 AM
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Document Crashes Word after update mjiskoot Word 1 11-12-2018 03:22 PM
Word 2004 Crashes, But Only With One Document Lee Charles Kelley Word 1 08-18-2011 12:28 PM
The &lt;toggleButton.../&gt; of the first document open crashes word when closing the second on Word crashes when closing mbjackson Word 1 02-06-2010 01:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:21 PM.


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