Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
moglione1
 
Posts: n/a
Default VBA Toolbar Ideas required


I have to create a new TOOLBAR in Excel that is generated when a specifc
spreadsheet is opened. E.g. When I open a TEST spreadsheet the code
looks for TEST ID and then creates a toolbar with pre-defined macro
buttons.

Does anybody know if this is possible. Any possible solutions will be
hulgely and greatly received.

I know how to create the toolbar manually but now when the document is
loaded


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=469808

  #2   Report Post  
dominicb
 
Posts: n/a
Default


Good morning moglione1

What you're asking here is actually pretty advanced stuff. The only
way I can think of doing this is by creating a toolbar "on the fly"
using VBA code and show using event procedures (Workbook_Open) and
delete it before the file is closed using the Workbook_Close
procedure.

The code to create a bar with one button is as follows:

Sub MyTB()
On Error Resume Next
Application.CommandBars("My Toolbar").Delete
Set TB = Application.CommandBars.Add(Name:="My Toolbar")
Set Btn = TB.Controls.Add(Type:=msoControlButton)
With Btn
.FaceId = 263
.OnAction = Macro1
End With
Application.CommandBars("My Toolbar").Visible = True
End Sub

When clicked the button will run Macro1. The image on the button is
no. 263 (use the utility from the link below to see them all).

http://www.oaltd.co.uk/DLCount/DLCou...e=BtnFaces.zip

To delete your toolbar use this code:

Sub KillToolbar()
Application.CommandBars("My Toolbar").Delete
End Sub

That bit's nice and easy...!

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=469808

  #3   Report Post  
dominicb
 
Posts: n/a
Default


Hi

Just had another thought. Why not build your toolbar, and then use a
macro to unhide it when your workbook is open, and hide it away again
when it closes. The toolbar will still be there, just hidden, so it
won't be immediatley viewable.

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=469808

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
Saving custom toolbars with macros to work on other computers jpw48 Excel Discussion (Misc queries) 11 August 29th 07 01:09 AM
Toolbar problem Anthony Excel Discussion (Misc queries) 1 June 1st 05 01:05 AM
how do I add sum function to the toolbar permanently speedy2 Excel Discussion (Misc queries) 1 May 21st 05 03:53 AM
How to prevent "Reviewing" toolbar from "automatically" appearing? FishHead Excel Discussion (Misc queries) 1 March 30th 05 05:00 PM
Is there a way to lock in the toolbar settings?? kydan47 Excel Discussion (Misc queries) 0 March 30th 05 02:13 PM


All times are GMT +1. The time now is 06:59 AM.

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"