Need help with PowerPoint macro that adds a new menu

K

Kim

Below is part of a macro I use to add a new menu with a drop-down
listing of the macros I need to use. I would like to add a picture
next to the name of the menu item (so the menu item will show the
picture, then the name of the menu item). I can customize the menu at
the menu bar, but it doesnt stay after I save a new .ppa file so I
need to get this into the code. Can anyone provide me the missing line
item I need to do this?

Option Explicit

Sub auto_open()

Dim cbmCommandBarMenu As CommandBar
Dim cbmPPTMacros As CommandBarPopup
Dim cbmCommandBarMenuCascade As CommandBarPopup

' Clear the way for new menu
On Error Resume Next
Application.CommandBars("Menu Bar").Controls("PPT Macros").Delete

' Identify built-in menu bar to work with
Set cbmCommandBarMenu = Application.CommandBars("Menu Bar")

' Add the new menu bar item: PPT Macros
With cbmCommandBarMenu.Controls
' By not specifying "Before", new menu will appear after Help menu
'Set cbmPPTMacros = .Add(Type:=msoControlPopup, Before:=10)
Set cbmPPTMacros = .Add(Type:=msoControlPopup)
' Set caption for new menu.
With cbmPPTMacros
.Caption = "PPT Macros"
' Add single menu item and set properties
With .Controls.Add(msoControlButton)
.OnAction = "OpenMSWordObject"
.Caption = "&A Open MSWord Object"
End With
 
S

Steve Rindsberg

Below is part of a macro I use to add a new menu with a drop-down
listing of the macros I need to use. I would like to add a picture
next to the name of the menu item (so the menu item will show the
picture, then the name of the menu item). I can customize the menu at
the menu bar, but it doesnt stay after I save a new .ppa file so I
need to get this into the code. Can anyone provide me the missing line
item I need to do this?

Option Explicit

Sub auto_open()

Dim cbmCommandBarMenu As CommandBar
Dim cbmPPTMacros As CommandBarPopup
Dim cbmCommandBarMenuCascade As CommandBarPopup

' Clear the way for new menu
On Error Resume Next
Application.CommandBars("Menu Bar").Controls("PPT Macros").Delete

' Identify built-in menu bar to work with
Set cbmCommandBarMenu = Application.CommandBars("Menu Bar")

' Add the new menu bar item: PPT Macros
With cbmCommandBarMenu.Controls
' By not specifying "Before", new menu will appear after Help menu
'Set cbmPPTMacros = .Add(Type:=msoControlPopup, Before:=10)
Set cbmPPTMacros = .Add(Type:=msoControlPopup)
' Set caption for new menu.
With cbmPPTMacros
.Caption = "PPT Macros"
' Add single menu item and set properties
With .Controls.Add(msoControlButton)
.OnAction = "OpenMSWordObject"
.Caption = "&A Open MSWord Object"
End With

I'm not sure there's a good way of inserting an arbitrary picture
directly via code, but you can get the image on the clipboard then use
the control's .PasteFace method to put the image on a button or
whatever.

One way of doing this is to open a new presentation w/o window so it's
invisible to the user; insert the picture you want to use for the
button; copy it to the clipboard; pasteface; close the invisible
presentation.
 
K

Kim

I'm not sure there's a good way of inserting an arbitrary picture
directly via code, but you can get the image on the clipboard then use
the control's .PasteFace method to put the image on a button or
whatever.

One way of doing this is to open a new presentation w/o window so it's
invisible to the user; insert the picture you want to use for the
button; copy it to the clipboard; pasteface; close the invisible
presentation.- Hide quoted text -

- Show quoted text -

Yes, I tried that, but it doesn't stick. I was just wondering if there
was code that I could write in to "hold" the pic in the menu name. PPT
VBA is next to nil, so I think I'm out of luck! Thanks for responding
though!
 
S

Steve Rindsberg

Yes, I tried that, but it doesn't stick. I was just wondering if there
was code that I could write in to "hold" the pic in the menu name. PPT
VBA is next to nil, so I think I'm out of luck! Thanks for responding
though!

It should work; how about posting the current version of the code that uses
.PasteFace though. Maybe someone can spot the problem.
 

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