Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a Toolbar to add-in

Hi there

I'm doing some VBA work on a spreadsheet and have got the code to read
through, validate and reformat. Now I want to do the following:

a) Write out the data as a text file (can use open etc. so no issues)
b) Have a new toolbar for the macro to run from (OK pretty easy I suppose)

However, I've seen something at my work where someone wrote something with a
..xla extension and double clicking on this meant that it auto-added the
toolbar into Excel and the object seemed to include macro stuff.

Is this done with VB6 and the Office SDK?

I'm also a VB programmer, but never turned my hand to do too much VBA
programming...only the simple stuff.

Any pointers would be great!

Thanks

Mike


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Creating a Toolbar to add-in

It doesn't need VB6 or the SDK to add a toolbar from code.

Here is some sample code to create a toolbar button on the Formatting as
suggested. This code would
go in the ThisWorkbok code module of the addin.

I would also add my usual corollary that to see what FaceIds are available,
visit John Walkenbach's site at http://j-walk.com/ss/excel/tips/tip67.htm

Option Explicit

Dim sMenu As String

Private Sub Workbook_BeforeClose(Cancel As Boolean)

sMenu = "myButton"

On Error Resume Next
Application.CommandBars("Formatting").Controls(sMe nu).Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
Dim oCtl As CommandBarControl
Dim newMenu As Object 'CommandBarControl
Dim ctrlButton As Object 'CommandBarControl

sMenu = "Margin Calculator"

On Error Resume Next
Application.CommandBars("Formatting").Controls(sMe nu).Delete
On Error GoTo 0

Set oCB = Application.CommandBars("Formatting")
Set oCtl = oCB.Controls.Add(Type:=msoControlButton, temporary:=True)

With oCtl
.BeginGroup = True
.Caption = sMenu
.FaceId = 197
.Style = msoButtonIconAndCaption
.OnAction = "myMacro"
End With

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mike Finister" wrote in message
...
Hi there

I'm doing some VBA work on a spreadsheet and have got the code to read
through, validate and reformat. Now I want to do the following:

a) Write out the data as a text file (can use open etc. so no issues)
b) Have a new toolbar for the macro to run from (OK pretty easy I suppose)

However, I've seen something at my work where someone wrote something with

a
.xla extension and double clicking on this meant that it auto-added the
toolbar into Excel and the object seemed to include macro stuff.

Is this done with VB6 and the Office SDK?

I'm also a VB programmer, but never turned my hand to do too much VBA
programming...only the simple stuff.

Any pointers would be great!

Thanks

Mike




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
Creating Custom Commands on a Toolbar rllngriver Excel Worksheet Functions 1 November 19th 07 07:07 PM
XLSTART-Creating a toolbar Andre Setting up and Configuration of Excel 2 November 1st 07 05:20 PM
Creating a Toolbar with a macro DavidP[_3_] Excel Programming 7 December 5th 03 10:22 AM
Creating a toolbar using VBA Phill Excel Programming 1 December 2nd 03 11:04 PM
Creating a button on Excel Toolbar Todd Huttenstine[_2_] Excel Programming 2 December 1st 03 11:28 PM


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

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"