#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBars

My application is a stand alone program that works with EXCEL.
What I want is a toolbar that when selected by EXCEL users, launches
my program.

My previous approach was to have the user start my program first, then
it would launch EXCEL, create my toolbar and create a code module (and
even load the users desired workbooks).

So I see how to create a PERMANENT toolbar, but where is the code
stored? I used to save it in a module named after my program.

After createing the permanent commandbar,I exit my program, and EXCEL.
When I restart EXCEL, my toolbar is there but when I click on any of
the commandbar controls, it wont run because it cant find my code.



Thanks gh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default CommandBars

Hi Garry,

My application is a stand alone program that works with EXCEL.
What I want is a toolbar that when selected by EXCEL users, launches
my program.


Distribute a small Excel addin that your users install. That adds the
menu item and handles the OnAction call by starting your app.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandBars

Synchronicity!
I got the idea to try an add-in this afternoon.

Of course, I'm stuck.


This add-in code will be generated into an xla created by myapp.exe
program during the installation proceedure.

(All because we don't know the path to myApp since the user could
install it anywhere!)

The desired behaviour is:
1. when user selects this add-in, a Permanent commandbar is created.
2. when user clicks button on commandbar, myapp is launched
3. when user unselects this add-in, the commandbar is removed.

Please recommend a better approach if you wish.

(I suppose I should check if commandbar exists before creating it.)


I just cant figure out what is the prefix (? instance?) of the current
running Excel.

Private Sub Workbook_AddinInstall()
'create PERMANENT toolbar
Dim cbar As CommandBar, cbct1 As CommandBarControl

MsgBox "install myAppTB"

'create myApptool bar as permanent

'error in next line- Me is wrong, so is Application, what should it be?
Set cbar = Me.CommandBars.Add("MyAppTB", msoBarTop, False, False)


cbar.Visible = True

'add MyApp button
Set cbct1 = cbar.Controls.Add(Id:=1) '(Type:=msoControlButton)
cbct1.Style = msoButtonCaption
cbct1.Caption = "Launch MyApp"
cbct1.OnAction = "Launch"
cbct1.Visible = True
'release all objects
Set cbct1 = Nothing
Set cbar = Nothing

End Sub

Private Sub Workbook_AddinUninstall()
'delete PERMANENT toolbar
MsgBox "Uninstall myappTB"
'have not figured this out yet"
End Sub



Private Sub launch()
MsgBox "launching myApp"
'shell "c:\myapp\myapp.exe 1 2 3", vbNormal
End Sub

Thanks again
Garry

http://www.visualstrongtype.com
Uncover nasty spreadsheet errors






*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default CommandBars

Hi Garry,

Private Sub Workbook_AddinInstall()
'create PERMANENT toolbar
Dim cbar As CommandBar, cbct1 As CommandBarControl

MsgBox "install myAppTB"

'create myApptool bar as permanent

'error in next line- Me is wrong, so is Application, what should it be?
Set cbar = Me.CommandBars.Add("MyAppTB", msoBarTop, False, False)


Application should work fine. Normally, I'd delete the toolbar
beforehand, just in case it's already the

On Error Resume next
Application.Commandbars("MyAppTB").Delete

On Error Goto 0
Set cbar = Me.CommandBars.Add("MyAppTB", msoBarTop, False, False)


Private Sub Workbook_AddinUninstall()
'delete PERMANENT toolbar
MsgBox "Uninstall myappTB"
'have not figured this out yet"


On Error Resume next
Application.Commandbars("MyAppTB").Delete

End Sub



Hope that helps

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie


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 CommandBars DRA Excel Discussion (Misc queries) 0 November 21st 06 11:28 PM
Disable Commandbars [email protected] Excel Programming 1 May 19th 04 07:29 AM
How to attach commandbars with VBA Carsten[_2_] Excel Programming 1 December 9th 03 12:55 PM
CommandBars defj Excel Programming 2 November 16th 03 12:57 AM
Built In CommandBars Sander Lablans Excel Programming 0 August 1st 03 11:59 AM


All times are GMT +1. The time now is 05:29 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"