' custoize classic UI in PowerPoint
' taken from Example07.vb

Private Sub Example07Main()

   Dim commandBar As Office.CommandBar = Nothing
   Dim commandBarBtn As Office.CommandBarButton = Nothing

   ' start powerpoint 
   Dim powerApplication As New PowerPoint.Application()
        
   ' add a new presentation with one new slide
   Dim presentation As PowerPoint.Presentation = _
powerApplication.Presentations.Add(MsoTriState.msoTrue) Dim slide As PowerPoint.Slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank) ' add a commandbar popup Dim commandBarPopup As Office.CommandBarPopup = _
powerApplication.CommandBars("Menu Bar").Controls.Add( _
MsoControlType.msoControlPopup) commandBarPopup.Caption = "commandBarPopup" ' you can see we use an own icon via .PasteFace() ' is not possible from outside process boundaries to use the PictureProperty
' directly the reason for is IPictureDisp:
' http://support.microsoft.com/kb/286460/de
' its not important is early or late binding or managed or unmanaged,
' the behaviour is always the same
' add a button to the popup commandBarBtn = commandBarPopup.Controls.Add(MsoControlType.msoControlButton) commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption commandBarBtn.Caption = "commandBarButton" Clipboard.SetDataObject(Me.Icon.ToBitmap()) commandBarBtn.PasteFace() Dim clickHandler As Office.CommandBarButton_ClickEventHandler = _
AddressOf Me.commandBarBtn_Click AddHandler commandBarBtn.ClickEvent, clickHandler 'add a new toolbar commandBar = powerApplication.CommandBars.Add("MyCommandBar", _
MsoBarPosition.msoBarTop, False, True) commandBar.Visible = True ' add a button to the toolbar commandBarBtn = commandBar.Controls.Add(MsoControlType.msoControlButton) commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption commandBarBtn.Caption = "commandBarButton" commandBarBtn.FaceId = 3 clickHandler = AddressOf Me.commandBarBtn_Click AddHandler commandBarBtn.ClickEvent, clickHandler ' add a dropdown box to the toolbar commandBarPopup = commandBar.Controls.Add(MsoControlType.msoControlPopup) commandBarPopup.Caption = "commandBarPopup" ' add a button to the popup, we use an own icon for the button commandBarBtn = commandBarPopup.Controls.Add(MsoControlType.msoControlButton) commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption commandBarBtn.Caption = "commandBarButton" Clipboard.SetDataObject(Me.Icon.ToBitmap()) commandBarBtn.PasteFace() clickHandler = AddressOf Me.commandBarBtn_Click AddHandler commandBarBtn.ClickEvent, clickHandler ' create context menu commandBarPopup = powerApplication.CommandBars("Frames").Controls.Add( _
MsoControlType.msoControlPopup) commandBarPopup.Caption = "commandBarPopup" ' add a button to the popup commandBarBtn = commandBarPopup.Controls.Add(MsoControlType.msoControlButton) commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption commandBarBtn.Caption = "commandBarButton" commandBarBtn.FaceId = 9 clickHandler = AddressOf Me.commandBarBtn_Click AddHandler commandBarBtn.ClickEvent, clickHandler ' make visible powerApplication.Visible = MsoTriState.msoFalse End Sub

Last edited Jun 13, 2012 at 2:20 PM by SebastianDotNet, version 5

Comments

No comments yet.