adding custom commandbutton's to Slide Show popup menu

G

ged6713

Hello All,

I am trying to develop a very simple add-in that will place a custom
menu item in (when looking at it through the Tools - Customize...) :

Shortcut Menus
SlideShow
Slide Show

In messing around with this I have been able to get it into the "Slide
Show Short Popup" menu (really close but does not show up when in
presentation mode) and then move it to the right place but I cannot
figure out to programatically place it where I need it.

At this point I suspected (and confirmed by Shyam's menu browse) that I
have some extraneous menus in there as a result due to naming issues
might be preventing me from getting a reference to the proper menu.

I used this as a starting point:
http://support.microsoft.com/?scid=kb;enus;302896&spid=2522&sid=251

I also tried using the Office XP PIA's with no luck.
Can anyone shed some light on this for me?

Thanks,

Eddie
 
G

ged6713

Ok,

I have now figured out how to do this....

for anyone that might be reading this:

goto
http://support.microsoft.com/?scid=kb;enus;302896&spid=2522&sid=251

do what it says and replace the OnStartupComplete Sub with the
following


Public Sub OnStartupComplete(ByRef custom As System.Array)
Implements Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
Dim oPopupBar As CommandBarPopup
Dim oPopupMenu As CommandBarPopup

On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars
If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer
object.
oCommandBars = applicationObject.ActiveExplorer.CommandBars
End If
Dim commandBarStr As String = "Shortcut Menus"
oStandardBar = oCommandBars.Item(commandBarStr)
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.
MsgBox("unknown commandbarItem: " & commandBarStr)
'oStandardBar = oCommandBars.Item("Database")

End If
Dim slideShowBarStr As String = "SlideShow"
oPopupBar = oStandardBar.Controls(slideShowBarStr)

If oPopupBar Is Nothing Then
MsgBox("unknown commandbarItem: " & slideShowBarStr)
End If

Dim slideShowMenuStr As String = "Slide Show"
oPopupMenu = oPopupBar.Controls(slideShowMenuStr)

If oPopupMenu Is Nothing Then
MsgBox("unknown commandbarItem: " & slideShowMenuStr)
End If


' In case the button was not deleted, use the exiting one.
MyButton = oPopupMenu.Controls.Item("My Custom Button")
If MyButton Is Nothing Then

MyButton = oPopupMenu.Controls.Add(1)
With MyButton
..Caption = "My Custom Button"
..Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is
required
' by some Office applications and should be provided.

..Tag = "My Custom Button"

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so that
if
' the add-in is not loaded when a user clicks the
button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

..OnAction = "!<MyCOMAddin.Connect>"

..Visible = True
End With
End If

' Display a simple message to show which application you
started in.
MsgBox("Started in " & applicationObject.Name & ".")


oStandardBar = Nothing
oCommandBars = Nothing


End Sub
 
G

ged6713

Now that I have this part.....


Does anyone know how to insert the button into the list rather than
simply tack it onto the end?


Thanks,

Eddie
 
G

ged6713

Well I sure hope this helps someone!!!

I figured out how to use the add method

MyButton = oPopupMenu.Controls.Add(, , , 2, )
which puts it BEFORE the 2nd element in the menu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top