Community
Hi
We have a problem at work with buttons disappearing from the quick access toolbar.
I already looked around and it is being said that it is a bug, wich can be fixed with a service pack. I work in a big company, and they are refusing to do the service pack.
So the next best thing I can figure is to make a macro, wich will add all the macros I want to the quick access toolbar in assembly level, part level, sketch level and drawing level.
But I have no idea how to start this.
Any tips are welcome.
Thank you
Hi there,
It would be possible to go through all the VBA macros and then add them like that, but this should help too I hope:
>>>>>
Sub AddMacros()
' List of Macros we want to add
Dim macros(1) As String
macros(0) = "Module2.qwe"
macros(1) = "Module1.test"
Dim cds As ControlDefinitions
Set cds = ThisApplication.CommandManager.ControlDefinitions
Dim ribbons As ribbons
Set ribbons = ThisApplication.UserInterfaceManager.ribbons
Dim macro As Variant
For Each macro In macros
' Check if there is already a ControlDefinition for it
Dim cd As ControlDefinition
For Each cd In cds
If TypeOf cd Is MacroControlDefinition And InStr(1, cd.InternalName, macro) > 0 Then
Exit For
End If
Next
' Add it if not
If cd Is Nothing Then
Set cd = cds.AddMacroControlDefinition(macro)
End If
Dim ribbon As ribbon
For Each ribbon In ribbons
' Check if QAT already contains it
Dim cc As CommandControl
For Each cc In ribbon.QuickAccessControls
If cc.ControlDefinition Is cd Then
Exit For
End If
Next
' Add it if not
If cc Is Nothing Then
Set cc = ribbon.QuickAccessControls.AddMacro(cd)
End If
Next
Next
End Sub
<<<<<
Cheers,