Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help on Toolbar

Ok, so I figured out how to create a macro that will creat a new toolba
for me, but when I run it, it creates the toolbar but none of th
buttons are correct. The toolbar is supposed to hold buttons that ru
other macros in the workbook. Am I doing something wrong?

From looking in VBA, it is only recording the below, however I a
entering more info during the recording of the macro. Any help will b
greatly appreciated!!


Sub TLD_Week_1()
'
' TLD_Week_1 Macro
' Macro recorded 6/13/2004 by Thomas
'

'
Application.CommandBars.Add(Name:="TLD Week 1 Performance").Visibl
= True
Application.CommandBars("TLD Week 1 Performance").Controls.Ad
Type:= _
msoControlButton, ID:=2950, Befo=1
Application.CommandBars("Stop Recording").Visible = False
Application.CommandBars("TLD Week 1 Performance").Visible = False
Application.WindowState = xlMinimized
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro Help on Toolbar

Here's a shell that I keep when I want to add a custom menubar:

In a general module:

Option Explicit
Sub create_menubar()

Dim i As Long

Dim mac_names As Variant
Dim cap_names As Variant
Dim tip_text As Variant

Call remove_menubar

mac_names = Array("mac1", _
"mac2", _
"mac3")

cap_names = Array("caption 1", _
"caption 2", _
"caption 3")

tip_text = Array("tip 1", _
"tip 2", _
"tip 3")

With Application.CommandBars.Add
.Name = "Test99"
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating

For i = LBound(mac_names) To UBound(mac_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name & "!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.FaceId = 71 + i
.TooltipText = tip_text(i)
End With
Next i
End With
End Sub

Sub remove_menubar()
On Error Resume Next
Application.CommandBars("Test99").Delete
On Error GoTo 0
End Sub


Under Thisworkbook:

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call remove_menubar
End Sub

Private Sub Workbook_Open()
Call create_menubar
End Sub

====
The Mac_names, cap_names, and tip_text are set up for 3 elements. But just
delete/add from each of these and the code will loop through them (even if
there's just one) to add buttons to a temporary toolbar.

(make sure you have the same number of elements for each array.)


"dok112 <" wrote:

Ok, so I figured out how to create a macro that will creat a new toolbar
for me, but when I run it, it creates the toolbar but none of the
buttons are correct. The toolbar is supposed to hold buttons that run
other macros in the workbook. Am I doing something wrong?

From looking in VBA, it is only recording the below, however I am
entering more info during the recording of the macro. Any help will be
greatly appreciated!!

Sub TLD_Week_1()
'
' TLD_Week_1 Macro
' Macro recorded 6/13/2004 by Thomas
'

'
Application.CommandBars.Add(Name:="TLD Week 1 Performance").Visible
= True
Application.CommandBars("TLD Week 1 Performance").Controls.Add
Type:= _
msoControlButton, ID:=2950, Befo=1
Application.CommandBars("Stop Recording").Visible = False
Application.CommandBars("TLD Week 1 Performance").Visible = False
Application.WindowState = xlMinimized
End Sub

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Help on Toolbar

Ok, I see how to do this now. But I do have a quick question. Th
.Position is set to floating. What would be the code to set it to b
attached to the toolbar?


With Application.CommandBars.Add
.Name = "Transition Lab Week 1 Productivity"
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloatin

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro Help on Toolbar

Highlight .position in the code and hit F1.

You'll see this:
Returns or sets the position of a command bar. Read/write MsoBarPosition.

Click on MsoBarPosition and you'll see these options.

msoBarBottom
msoBarFloating
msoBarLeft
msoBarMenuBar
msoBarPopup
msoBarRight
msoBarTop


I like the floating to make sure that the user (including me!) sees this new
toolbar.

"dok112 <" wrote:

Ok, I see how to do this now. But I do have a quick question. The
Position is set to floating. What would be the code to set it to be
attached to the toolbar?

With Application.CommandBars.Add
Name = "Transition Lab Week 1 Productivity"
Left = 200
Top = 200
Protection = msoBarNoProtection
Visible = True
Position = msoBarFloating

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
TOOLBAR FOR A MACRO FARAZ QURESHI Excel Discussion (Misc queries) 3 July 3rd 08 12:12 PM
Macro button on toolbar Daniel Charts and Charting in Excel 0 August 27th 07 08:56 PM
macro in toolbar jatman Excel Discussion (Misc queries) 1 September 21st 06 08:25 AM
macro toolbar Ankur Excel Discussion (Misc queries) 3 August 5th 06 01:55 AM
toolbar macro for esp. worksheet Mauricio[_2_] Excel Programming 1 November 11th 03 08:43 PM


All times are GMT +1. The time now is 11:30 PM.

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

About Us

"It's about Microsoft Excel"