3 Replies - 1087 Views - Last Post: 03 May 2018 - 01:40 AM Rate Topic: -----

#1 mike944   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 17-February 13

Add Powerpoint custom toolbar with VBA - icon size too small

Posted 02 May 2018 - 07:36 AM

Hi everybody,

Trying to create a custom toolbar in Powerpoint 2010. It works, but the icons are so small I can't tell what they are.

I want something that looks like this: http://www.add-in-ex...ibbonDesign.png

I'm using a VBA script to generate the "add-ins" bar, and add buttons to it with msoControlButton.add The size modifiers (.height and .width) don't seem to do anything. My icon images are adequately large (48x48).

What am I doing wrong?


Sub Auto_Open()
    Dim oToolbar As CommandBar
    Dim oButton1 As CommandBarButton
    Dim oButton2 As CommandBarButton
    Dim oButton3 As CommandBarButton
    Dim oButton4 As CommandBarButton
    Dim MyToolbar As String

    ' Give the toolbar a name
    MyToolbar = "Marking Tools"

    On Error Resume Next
    ' so that it doesn't stop on the next line if the toolbar's already there

    ' Create the toolbar; PowerPoint will error if it already exists
    Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
        Position:=msoBarFloating, Temporary:=True)
    If Err.Number <> 0 Then
          ' The toolbar's already there, so we have nothing to do
          Exit Sub
    End If

    On Error GoTo ErrorHandler

Set picPicture1 = stdole.StdFunctions.LoadPicture("D:\M1.gif")
Set picPicture2 = stdole.StdFunctions.LoadPicture("D:\M2.gif")
Set picPicture3 = stdole.StdFunctions.LoadPicture("D:\M3.gif")

    ' Now add a button to the new toolbar
    Set oButton1 = oToolbar.Controls.Add(Type:=msoControlButton)

    ' And set some of the button's properties
    With oButton1
    
         .Width = 50 'doesn't seem to do anything
         .Caption = "Mark 1"
         .DescriptionText = "Mark Page with: Marking 1"
          'Tooltip text when mouse if placed over button

         .OnAction = "Mark_Slide_1"
          'Runs the Sub Mark_Slide_1() code when clicked

         .Style = msoButtonIconAndCaptionBelow
          ' Button displays as icon, not text or both

         .Picture = picPicture1
    

    End With

    Set oButton2 = oToolbar.Controls.Add(Type:=msoControlButton)
        
        With oButton2
         .Width = 50
         .Caption = "Mark 2"
         .DescriptionText = "Mark Page with: Marking 2"
          'Tooltip text when mouse if placed over button

         .OnAction = "Mark_Slide_2"
          'Runs the Sub Mark_Slide_1() code when clicked

         .Style = msoButtonIconAndCaptionBelow
          ' Button displays as icon, not text or both

         .Picture = picPicture2
    

    End With
    
    
    Set oButton3 = oToolbar.Controls.Add(Type:=msoControlButton)
    
            With oButton3

         .Width = 50
         .Caption = "Mark 3"
         
         .DescriptionText = "Mark page with: Marking 3"
          'Tooltip text when mouse if placed over button

         .OnAction = "Mark_Slide_3"
          'Runs the Sub Mark_Slide_3() code when clicked

         .Style = msoButtonIconAndCaptionBelow
          ' Button displays as icon, not text or both

         .Picture = picPicture3
    

    End With
    
    oToolbar.Top = 150
    oToolbar.Left = 150
    oToolbar.Visible = True

NormalExit:
    Exit Sub   ' so it doesn't go on to run the errorhandler code

ErrorHandler:
     'Just in case there is an error
     MsgBox Err.Number & vbCrLf & Err.Description
     Resume NormalExit:
End Sub





BTW, I'm on a large corporate network, and I can't download and install software such as Visual studio, or a ribbon customizer tool.

Is This A Good Question/Topic? 0
  • +

Replies To: Add Powerpoint custom toolbar with VBA - icon size too small

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14685
  • View blog
  • Posts: 58,688
  • Joined: 12-June 08

Re: Add Powerpoint custom toolbar with VBA - icon size too small

Posted 02 May 2018 - 07:45 AM

IS there an 'AutoSize' property you can set to true? Maybe set a 'BorderStyle' to 'style none'?

I want to say I remember the sizing being in 'points' and not 'pixels'.
Was This Post Helpful? 0
  • +
  • -

#3 mike944   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 17-February 13

Re: Add Powerpoint custom toolbar with VBA - icon size too small

Posted 02 May 2018 - 08:36 AM

Nope, neither of those work. Thanks for the ideas though
Was This Post Helpful? 0
  • +
  • -

#4 maceysoftware   User is offline

  • Foo
  • member icon

Reputation: 367
  • View blog
  • Posts: 1,569
  • Joined: 07-September 13

Re: Add Powerpoint custom toolbar with VBA - icon size too small

Posted 03 May 2018 - 01:40 AM

Microsoft Knowledgebase is your friend on this one:

https://msdn.microso...operties-office

Just to confirm I have never done this, however, on your toolbar there seems to be a property called LargeButtons, if you set that to true, I would assume that every button in that toolbar will become large.

If that doesn't help then on the CommandBarButton, you seem to be able to set the width and height of the buttons manually, try that if you only want one button to be large.
https://msdn.microso...operties-office
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1