Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-18-2023, 04:56 AM
Ddadoo57 Ddadoo57 is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2021
Advanced Beginner
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?

Hello,



I have a problem that I can't solve for a long time now ;-(

When I open 2 documents created with the same .dotm template, both documents share the same instance of the custom ribbon.

For example: if I click on a toggleButton in one of the 2 opened documents, the TB in the other document goes to the same state.

Could someone give me some hints or help me to solve this very difficult problem and/or has someone already done this experience?

Thanks in advance!
David

PS: just for information, when you open 2 documents based on the same template, the loading of the custom ribbon is done only once, i.e. Sub MyRibbon_OnLoad(ribbon As IRibbonUI) is executed only once, when loading the first document
Reply With Quote
  #2  
Old 03-18-2023, 06:36 PM
Guessed's Avatar
Guessed Guessed is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 10 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
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

Can you show us an example template that we can do testing on - it is kind of arduous to create one before we can start testing ideas on a solution
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-19-2023, 03:24 AM
Italophile Italophile is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? 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

The ribbon is an application object, not a document object.

Your code needs to handle the DocumentChange event so that you can refresh the ribbon when the active document changes.

Your toggle buttons also need to have GetPressed callbacks so that the button reflects the current state of the property that is being toggled.
Reply With Quote
  #4  
Old 03-19-2023, 08:11 AM
Ddadoo57 Ddadoo57 is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2021
Advanced Beginner
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

Thanks a lot Guessed and Italophile!

I will do some more testing and keep you posted!

- Italophile, yes the ribbon should be an application object and that's why I was surprised by the behavior I encountered. I'll move some lines of code to my App_DocumentChange event. As for the getPressed and getEnabled callbacks, after trying the same code in each, I have no change.

- Guessed, yes we will do that if I can't optimize my current code.

The solution in the meantime that I have, is the following: for each opened document I have a unique temporary variable, in which is indicated the TB activated for this document. If I change the document on the screen, I take the value of the temporary variable of the document and I activate its TB... with that I don't have any problem but it's true it's a DIY.

Have a nice day,
David
Reply With Quote
  #5  
Old 03-19-2023, 04:20 PM
Italophile Italophile is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? 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

You should get yourself a copy of RibbonX: Customizing the Office 2007 Ribbon.

getPressed and getEnabled do very different things so the code should definitely not be the same.

Here is an example of how getPressed is used.

Code:
Public Sub getPressed(control As IRibbonControl, ByRef returnedVal)
    'callback for toggle button that turns ShowPicturePlaceholders on / off
    returnedVal = ActiveDocument.ActiveWindow.View.ShowPicturePlaceHolders
End Sub
Your DocumentChange event should check whether the active document is based on your template and, if so, refresh the ribbon.
Reply With Quote
  #6  
Old 03-20-2023, 01:29 AM
Ddadoo57 Ddadoo57 is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2021
Advanced Beginner
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

Thanks for your feedback, Italophile !

yes getEnabled and getPressed are of course different, it's just that in another post you talked about GetEnabled or GetVisible callbacks. So I had tried 2-3 things to see if it could change something to the problem.

Here is what I understand: getEnabled for the enabled attribute of the element (if the element is grayed or not), getPressed to know the state of the element (if it is pressed/selected or not), and onAction for the action to be taken.

I hope to have some time today to do some testing.

Have a nice day,
David
Reply With Quote
  #7  
Old 03-20-2023, 02:03 AM
Ddadoo57 Ddadoo57 is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2021
Advanced Beginner
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

I had my objRibbon's statement in Public, maybe that didn't help. I put it in Private.
Reply With Quote
  #8  
Old 03-21-2023, 05:34 AM
Ddadoo57 Ddadoo57 is offline Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Windows 11 Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Office 2021
Advanced Beginner
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template?
 
Join Date: Feb 2023
Posts: 71
Ddadoo57 is on a distinguished road
Default

Hi Italophile and Guessed!

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
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Is it possible to choose another NORMAL.DOTM in WORD as template for merge documents using VBA? DDouma1964 Word VBA 1 08-17-2022 08:18 AM
Automatic link creation, after writing: Link text in main body (multiple instances) mike_302 Word VBA 2 07-05-2021 12:28 AM
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Word Custom Ribbon In .dotm - How to edit/create? s0me0nesmind1 Word 6 04-16-2020 04:10 PM
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Create custom quote based on template torma156 Word 3 09-06-2015 11:04 AM
Dissociate instance of a custom ribbon, for documents based on the same dotm creation template? Documents hung up, Word won't close due to "Changes made..to global template Normal.dotm" pagskg Word 2 07-23-2014 12:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:47 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