Note: I did post this question also on StackOverflow and Docs.Microsoft.com:
https://stackoverflow.com/questions/...creen-is-empty. Here I have had many help already, but not for this problem.
https://docs.microsoft.com/en-us/ans...owerpoint.html.
I could not solve the problem yet, so that is why I post it here also and hope to find a solution ...
I am making an add-in with a custom Ribbon Tab. When PowerPoint is opened, and the add-in is loaded, the user only sees three buttons on the custom Tab (= the choice between three templates) which can be used to start a new presentation.
When template A is choosen to make a new presentation, group 1 (with a set of buttons) gets visible on the custom Ribbon Tab.
When the presentation is closed, the group disappears. When template B is choosen, group 2 appears. When template C is choosen, group 3 appears. The groups are never visible all together.
So everytime a presentation is new created, closed or opened, the Ribbon has to refresh. The Getvisible code is checking the Design name of the template to see which group has to be visible.
This works fine as long as there is already a presentation open on screen. But as soon as there is no presentation open (empty PowerPoint screen) and a new presentation is made via the custom Tab, the Ribbon does not refresh. The template-depended group does not appear in the Ribbon. This also happens when I open an existing presentation on an empty screen. I can also see in another way that the Ribbon is not refreshed because of the fact that after the Event, the Ribbon does not go back to the Home Tab.
I can't figure out where it goes wrong. Here is my code:
XML:
<customUI onLoad="RibbonOnLoad" …>
<group id="MyCustomGroup1" label="Name" getVisible="GetVisible" tag="MyPersonalGroup1"
And there I've added some custom buttons.
I also made "MyPersonalGroup2" and "MypersonalGroup3" like this.
VBA:
Dim Rib As IRibbonUI
Dim MyTag As String
'Callback for customUI.onLoad
Sub RibbonOnLoad(ribbon As IRibbonUI)
Set Rib = ribbon
MsgBox "Ribbon Loaded"
End Sub
Sub getVisible(control As IRibbonControl, ByRef returnedVal)
Select Case control.Tag
Case "MyPersonalGroup1"
returnedVal = ActiveWindow.Selection.SlideRange.Design.Name = ("TemplateA")
Case "MyPersonalGroup2"
returnedVal = ActiveWindow.Selection.SlideRange.Design.Name = ("TemplateB")
Case "MyPersonalGroup3"
returnedVal = ActiveWindow.Selection.SlideRange.Design.Name = ("TemplateC")
End Select
End Sub
Class module ApplicationEventClass:
Public WithEvents PPTEvent As Application
Private Sub PPTEvent_WindowSelectionChange(ByVal Sel As Selection)
MyTag = Tag
If Rib Is Nothing Then
MsgBox "Error, restart your presentation"
Else
Rib.Invalidate
End If
End Sub
I repeated this code for 'PPTEvent_NewPresentation' 'PPTEvent_AfterNewPresentation' 'PPTEvent_AfterPresentationOpen' 'PPTEvent_PresentationOpen' 'PPTEvent_PresentationClose'
And this Module going with the code above:
Dim X As New ApplicationEventClass
Sub InitializePPTEvent()
Set X.PPTEvent = Application
End Sub
Help is very much appreciated!