Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How do I add a vertical spacer bar in toolbar

I have some VBA code that creates a new toolbar when I open the
spreadsheet. The toolbar has two buttons on it which are labelled with
words rather than an icon. The two buttons run other macros. I would
like to include some additional code that will place a vertical spacer
bar between the two buttons so that they look more separated on the screen.

I have tried recording a macro whilst doing the process manually but the
macro had no code in it when I finished.

Can anybody tell me what the code is that I should use? I am using XL97
on Win NT 4.

The code that creates the toolbar is as follows:


Sub MakeToolBar()

Dim Ctl As CommandBarControl

On Error Resume Next
Application.CommandBars("Sorting projects").Delete
On Error GoTo 0

'Create the toolbar
Application.CommandBars.Add ("Sorting projects")

'Add the first button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Funding Source"
.TooltipText = "Sort and subtotal by Funding Source"
.OnAction = "Subtotal_By_Funder"
End With

'Add the second button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Work Stage"
.TooltipText = "Sort and subtotal by Work Stage"
.OnAction = "Subtotal_By_Stage"
End With

'Make toolbar visible
Application.CommandBars("Sorting projects").Visible = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default How do I add a vertical spacer bar in toolbar

Hi Graham,

For your 2nd Button you have to set it's BeginGroup Property to True.

ctl.BeginGroup = True

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
(Excel Add-ins)



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default How do I add a vertical spacer bar in toolbar

Hi Graham,

Add the following within the second Ctl With statement

..BeginGroup = True


Graham Standring wrote:

I have some VBA code that creates a new toolbar when I open the
spreadsheet. The toolbar has two buttons on it which are labelled with
words rather than an icon. The two buttons run other macros. I would
like to include some additional code that will place a vertical spacer
bar between the two buttons so that they look more separated on the screen.

I have tried recording a macro whilst doing the process manually but the
macro had no code in it when I finished.

Can anybody tell me what the code is that I should use? I am using XL97
on Win NT 4.

The code that creates the toolbar is as follows:


Sub MakeToolBar()

Dim Ctl As CommandBarControl

On Error Resume Next
Application.CommandBars("Sorting projects").Delete
On Error GoTo 0

'Create the toolbar
Application.CommandBars.Add ("Sorting projects")

'Add the first button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Funding Source"
.TooltipText = "Sort and subtotal by Funding Source"
.OnAction = "Subtotal_By_Funder"
End With
'Add the second button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Work Stage"
.TooltipText = "Sort and subtotal by Work Stage"
.OnAction = "Subtotal_By_Stage"
End With

'Make toolbar visible
Application.CommandBars("Sorting projects").Visible = True

End Sub



--

Cheers
Andy

http://www.andypope.info

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How do I add a vertical spacer bar in toolbar

Thanks to both Andy and Shailesh.

Placing the .BeginGroup command within the second "With Ctl" statement
did not work but through trial and error, and of course having been made
aware by you of that command, I managed to make it work by putting the
following line after the second "With Ctl" statement.

Application.CommandBars("Sorting projects").Controls(2).BeginGroup = True

Thanks for your help.

Graham


Andy Pope wrote:

Hi Graham,

Add the following within the second Ctl With statement

.BeginGroup = True


Graham Standring wrote:

I have some VBA code that creates a new toolbar when I open the
spreadsheet. The toolbar has two buttons on it which are labelled
with words rather than an icon. The two buttons run other macros. I
would like to include some additional code that will place a vertical
spacer bar between the two buttons so that they look more separated
on the screen.

I have tried recording a macro whilst doing the process manually but
the macro had no code in it when I finished.

Can anybody tell me what the code is that I should use? I am using
XL97 on Win NT 4.

The code that creates the toolbar is as follows:


Sub MakeToolBar()

Dim Ctl As CommandBarControl

On Error Resume Next
Application.CommandBars("Sorting projects").Delete
On Error GoTo 0

'Create the toolbar
Application.CommandBars.Add ("Sorting projects")

'Add the first button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Funding Source"
.TooltipText = "Sort and subtotal by Funding Source"
.OnAction = "Subtotal_By_Funder"
End With
'Add the second button
Set Ctl = Application.CommandBars("Sorting projects").Controls.Add
With Ctl
.Style = msoButtonCaption
.Width = 112
.Caption = "Subtotal by Work Stage"
.TooltipText = "Sort and subtotal by Work Stage"
.OnAction = "Subtotal_By_Stage"
End With

'Make toolbar visible
Application.CommandBars("Sorting projects").Visible = True

End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make a vertical report export into a vertical report? April Excel Discussion (Misc queries) 3 January 18th 10 11:13 PM
Vertical line isn't vertical! [email protected] Charts and Charting in Excel 2 September 13th 06 01:54 PM
Vertical line isn't vertical! Ray Excel Discussion (Misc queries) 0 September 12th 06 02:33 PM
Vertical line in a histogram (vertical bar chart) AdamCPTD Excel Discussion (Misc queries) 0 July 13th 06 09:43 PM
How do i insert of spacer rows between rows in large spreadsheets laurel Excel Discussion (Misc queries) 0 April 24th 06 01:38 PM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"