Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default how to remove command bar button

How I can remove the custom command bar which I want to
add automaticaly when excel file is open.
Adding is done by the following procedu

Sub Workbook_Open()

Dim c As CommandBar
Dim cb As CommandBarButton
Dim cp As CommandBarPopup

On Error Resume Next
Set c = Application.CommandBars("Worksheet Menu Bar")
If Not c Is Nothing Then
Set cb = c.Controls.Add(msoControlButton, 2)
cb.Style = msoButtonCaption
cb.Caption = "Calculate Totals"
cb.OnAction = "Template 4.xls!
ThisWorkbook.Calculate"
End If

End Sub

Thanks for help.

Regards,

Tony


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default how to remove command bar button

Hi Tony,

Here's one way to do it:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar") _
.Controls("Calculate Totals").Delete
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Tony" wrote in message
...
How I can remove the custom command bar which I want to
add automaticaly when excel file is open.
Adding is done by the following procedu

Sub Workbook_Open()

Dim c As CommandBar
Dim cb As CommandBarButton
Dim cp As CommandBarPopup

On Error Resume Next
Set c = Application.CommandBars("Worksheet Menu Bar")
If Not c Is Nothing Then
Set cb = c.Controls.Add(msoControlButton, 2)
cb.Style = msoButtonCaption
cb.Caption = "Calculate Totals"
cb.OnAction = "Template 4.xls!
ThisWorkbook.Calculate"
End If

End Sub

Thanks for help.

Regards,

Tony




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to remove command bar button

Also, when creating it, you can make it temporary

Set cb = c.Controls.Add(msoControlButton, 2,temporary:=true)


--

HTH

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

"Rob Bovey" wrote in message
...
Hi Tony,

Here's one way to do it:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar") _
.Controls("Calculate Totals").Delete
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Tony" wrote in message
...
How I can remove the custom command bar which I want to
add automaticaly when excel file is open.
Adding is done by the following procedu

Sub Workbook_Open()

Dim c As CommandBar
Dim cb As CommandBarButton
Dim cp As CommandBarPopup

On Error Resume Next
Set c = Application.CommandBars("Worksheet Menu Bar")
If Not c Is Nothing Then
Set cb = c.Controls.Add(msoControlButton, 2)
cb.Style = msoButtonCaption
cb.Caption = "Calculate Totals"
cb.OnAction = "Template 4.xls!
ThisWorkbook.Calculate"
End If

End Sub

Thanks for help.

Regards,

Tony






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
Remove Command Button After Click andiam24 Excel Discussion (Misc queries) 4 April 1st 09 04:51 PM
How do you remove a macro command button? Dave Rowe Excel Discussion (Misc queries) 1 July 25th 07 04:16 AM
How to remove all instances of a command button larjani Excel Discussion (Misc queries) 0 December 22nd 06 03:20 AM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 01:41 PM.

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"