The Word-Plugin did not work for me, since we have a customized menu bar,
where one item is not of type CommandBarPopup.
So, attached you can find a modified version of InstallSvnMenu and
DeleteSvnMenu, where the type is checked and only if it is or correct type
it is casted.
Red is your original code, green my modifications.
You are welcome to use my changes in your code.
---
Sub InstallSvnMenu()
' Menu control object
'Dim ctlMainMenu As CommandBarPopup
Dim ctlMainMenu As CommandBarControl
Dim ctlMainMenuPopup As CommandBarPopup
Dim mnuSvn As CommandBarControl
Dim mnuSub1 As CommandBarButton
Dim mnuSub2 As CommandBarButton
Dim mnuSub3 As CommandBarButton
Dim mnuSub4 As CommandBarButton
Dim mnuSub5 As CommandBarButton
Dim mnuSub6 As CommandBarButton
Dim mnuSub7 As CommandBarButton
Dim mnuSub8 As CommandBarButton
Dim mnuSub9 As CommandBarButton
Dim mnuSub10 As CommandBarButton
' If Subversion menu control already exists, exit subroutine
' Orig Code... does not work
'For Each ctlMainMenu In Application.CommandBars(gMainMenuName).Controls
' If ctlMainMenu.Caption = gcapSvnMenuBar Then
' Exit Sub
' End If
'Next
For Each ctlMainMenu In Application.CommandBars(gMainMenuName).Controls
If ctlMainMenu.Type = msoControlPopup Then
Set ctlMainMenuPopup = ctlMainMenu
If ctlMainMenuPopup.Caption = gcapSvnMenuBar Then
Exit Sub
End If
End If
Next
… rest identical
Sub DeleteSvnMenu()
' Orig Code... does not work
' Command bar control object
'Dim ctlMainMenu As CommandBarPopup
' If Subversion menu exists, delete it.
'For Each ctlMainMenu In Application.CommandBars(gMainMenuName).Controls
' If ctlMainMenu.Caption = gcapSvnMenuBar Then
' Application.CommandBars(gMainMenuName).Controls(gcapSvnMenuBar).Delete
' End If
'Next
' New Code by RB...
Dim ctlMainMenu As CommandBarControl
Dim ctlMainMenuPopup As CommandBarPopup
' If Subversion menu exists, delete it.
For Each ctlMainMenu In Application.CommandBars(gMainMenuName).Controls
If ctlMainMenu.Type = msoControlPopup Then
Set ctlMainMenuPopup = ctlMainMenu
If ctlMainMenuPopup.Caption = gcapSvnMenuBar Then
Application.CommandBars(gMainMenuName).Controls(gcapSvnMenuBar).Delete
End If
End If
Next
End Sub
---
Original issue reported on code.google.com by kok...@gmail.com on 28 Oct 2009 at 3:09
Original issue reported on code.google.com by
kok...@gmail.com
on 28 Oct 2009 at 3:09