Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Add Commandbar when Add-in is install

Hi all,
I have this code, it works really well if I put it in workbook_open() event.
But I need the commandbar active when user install the add-in file. and
delete it when the add-in is removed
Thanks for your help

Private Sub Workbook_Open()

Dim oCb As CommandBar
Dim oCtl As CommandBarButton

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("Import
Text").Delete
On Error GoTo 0
Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "Import Text"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "ImportText"
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Add Commandbar when Add-in is install

That should be okay as is as it will load when the workbook opens, that is
when it is installed and when Excel starts.

You should delete it when the addin closes

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar") _
.Controls("Import Text").Delete
On Error GoTo 0
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"A.Q" wrote in message
...
Hi all,
I have this code, it works really well if I put it in workbook_open()

event.
But I need the commandbar active when user install the add-in file. and
delete it when the add-in is removed
Thanks for your help

Private Sub Workbook_Open()

Dim oCb As CommandBar
Dim oCtl As CommandBarButton

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("Import
Text").Delete
On Error GoTo 0
Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "Import Text"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "ImportText"
End With
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
try to install a security update, prompted to install PRO11.msi najib Setting up and Configuration of Excel 0 June 4th 08 05:43 PM
What program do I install to install office 2003 with no prior pro lwd Excel Discussion (Misc queries) 1 January 8th 06 09:37 PM
cant dim as commandbar Seren Excel Programming 1 December 21st 05 09:18 PM
Why does PHStats *NOT* install when I install Analytical ToolPak? webeditor-coutre Setting up and Configuration of Excel 1 July 5th 05 06:58 AM
commandbar Greg Prost[_2_] Excel Programming 2 November 21st 03 11:42 AM


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