View Full Version : I'm making PPT Addin and cant get buttons to arrange vertical!
avitzavi
01-30-2017, 05:06 PM
Hello all,
Ive made a custom addin for 4 macros ive made and the buttons show up but are arranged horizontally and I want them vertically.
Is this possible? You can see in the picture attached that the left set of commands that someone sent me are vertical. My 4 macros to the right are not!
18198
Paul_Hossler
01-31-2017, 06:59 AM
http://www.vbaexpress.com/forum/showthread.php?54808-How-to-limit-the-ribbon-to-2-normal-size-icons-per-column
Post #2 has example of using <box> tag in CustomUI
avitzavi
01-31-2017, 07:55 AM
Hey,
Thanks for the quick reply. Ill go check it out!
avitzavi
01-31-2017, 07:58 AM
That thread was for making buttons on the ribbon in XML while I've been using VBA to make mine. As such it likely wont work for me =\
John Wilson
01-31-2017, 10:21 AM
You should be using open XML if you have a version from 2007 onwards. You will find the command bars method in vba extremely limited. The three vertical menus were almost certainly programmed in XML.
avitzavi
01-31-2017, 10:37 AM
The three vertical menus were almost certainly programmed in XML.
in fact they are not.
I have their source code and I think the only difference is that when menus (and not buttons) are used, they stack vertically by default.
I only plan on including 4-10 macros activated by buttons in the ribbon and (they will normally be run by: ALT+X+C or something like that. I think the non-XML method suits me well enough for this, I just wish I could make them look the way I want.
Is there an easy way (maybe a tutorial) to convert my VBA code into XML? This is a small side project and I dont really have time to learn new languages/syntax just for a cosmetic issue.
John Wilson
01-31-2017, 11:32 AM
If you code in vba for menus which in 2003 (where it is the correct method) they would appear as new menus on the toolbar. Since the toolbar doesn't exist as such in 2007 on it will do the best it can. Sometimes it just will fail and other times it stacks them as you have in the AddIns tab. If you program toolbars, as I guess you have, it will show as a single row unless you add a new command bar for each button (which would be clumsy). There is very little control. The XML method gives you the control you need (and much more) but as you say it's a new skill to learn.
avitzavi
02-02-2017, 03:29 PM
Hey, I think there might be a way to include XML code in my VBA version already?
for reference, here is what i have so far:
Sub Auto_Open()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim MyToolbar As String
' Give the toolbar a name
MyToolbar = "Analyst Toolkit"
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
'oToolbar.Width = 100
On Error GoTo ErrorHandler
'Button 1
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
With oButton
.DescriptionText = "Copy Size & Position"
.Caption = "&Copy Size/Position"
.OnAction = "CopyPositionSize"
'Runs the Sub CopyPositionSize() code when clicked
.Style = msoButtonIconAndWrapCaption
.FaceId = 3985
End With
'Button 2
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
With oButton
.DescriptionText = "Paste Size & Position"
.Caption = "&Paste Size/Position"
.OnAction = "PastePositionSize"
'Runs the Sub CopyPositionSize() code when clicked
.Style = msoButtonIconAndWrapCaption
.FaceId = 4157
End With
'Button 3
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
With oButton
.BeginGroup = True
.DescriptionText = "Save Copy with No Links"
.Caption = "Export and &Break Links"
.OnAction = "BreakAllLinks"
'Runs the Sub CopyPositionSize() code when clicked
.Style = msoButtonIconAndWrapCaption
.FaceId = 2647
End With
'Button 4
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
With oButton
.DescriptionText = "Save Copy with No Links"
'Tooltip text when mouse if placed over button
.Caption = "Export, Break Links and &Email"
'Text if Text in Icon is chosen
.OnAction = "BreakAllLinksAndEmail" 'Runs the Sub CopyPositionSize() code when clicked
.Style = msoButtonIconAndWrapCaption
.FaceId = 2986
End With
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
John Wilson
02-03-2017, 12:44 AM
There's a start tutorial for using XML in the ribbon (http://www.pptalchemy.co.uk/custom_UI.html) on our page. Look at the last sample and simply remove size="large" in each line leaving just a space which will give you small buttons stacked in threes.
Really, you are just making work for yourself using Steve's very old legacy code which is from a version over 10 years old.
John Wilson
02-03-2017, 07:31 AM
Here's a sample
John Wilson
02-03-2017, 07:34 AM
Here's a sample (spelling corrected)
18233
Paul_Hossler
02-03-2017, 08:03 AM
A good reference is
https://msdn.microsoft.com/en-us/library/dd910855(v=office.12).aspx
and I added an example and code and etc. to the other post in the Ribbon forum
http://www.vbaexpress.com/forum/showthread.php?54808-How-to-limit-the-ribbon-to-2-normal-size-icons-per-column
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.