PDA

View Full Version : Remove a custom group/button from the ribbon



JBSMichael
12-10-2018, 09:12 AM
I have a macro in MS Project 2010 that I would like to run from a button in the ribbon. So far, so easy: just add a custom group and a custom button in the ribbon customiser. However, I want to add some code that will a) add a similar button when other users open the file; and b) remove that customisation first (if it already exists) before then adding the button back. This question is about the second part - clearing customisation (or at least this specific button - the button is called "Export Reporting Data" and is in the custom group "Reporting").

From Microsoft I got the following, which purports to clear all customised elements:


Sub RemoveCustomUI()
Dim customUiXml As String

customUiXml = "<mso:customUIxmlns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">" _
& "<mso:ribbon></mso:ribbon></mso:customUI>"

ActiveProject.SetCustomUI (customUiXml)

End Sub

However, this doesn't work for me in Project 2010. Can anyone help please? Thank you...

MJ

Andy Pope
12-13-2018, 02:27 AM
I don't have Project in order to test but I think the issue is a missing space in the string you generate.
You need to seperate customUIxml from the start of the schema namespace,
mso:customUIxml ns:mso



Sub RemoveCustomUI()
Dim customUiXml As String

customUiXml = "<mso:customUIxml ns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">" _
& "<mso:ribbon></mso:ribbon></mso:customUI>"

ActiveProject.SetCustomUI (customUiXml)

End Sub

JBSMichael
12-13-2018, 12:51 PM
Thanks so mich for taking the time Andy. I’ll give it a go and let you know how I get on.

Mike


I don't have Project in order to test but I think the issue is a missing space in the string you generate.
You need to seperate customUIxml from the start of the schema namespace,
mso:customUIxml ns:mso



Sub RemoveCustomUI()
Dim customUiXml As String

customUiXml = "<mso:customUIxml ns:mso=""http://schemas.microsoft.com/office/2009/07/customui"">" _
& "<mso:ribbon></mso:ribbon></mso:customUI>"

ActiveProject.SetCustomUI (customUiXml)

End Sub