Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Duplicate ToolBar Buttons

Greetings !

I have some routines in the "WorkbookOpen" routine
of various workbooks that create ToolBar buttons.

Generally, I have managed to get the relevant buttons
deleted when the workbook is closed, but what I haven't
yet
managed is to prevent new duplicate buttons being created.

Would SKS be so kind as to give me the relevant code ?

e.g.

Public Sub MakeButtons()

' Make "Print" button

If Exists Button(Print) Then ' <--- It's this line I
need help with !

Else
'Existing Make "Print" button routine goes here

End If


' Repeat for the other buttons


End Sub


RClay AT haswell DOT com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Duplicate ToolBar Buttons

Robin

I have a similar problem and appear (only just tried this!) to have a
solution by adding the following line to my Workbook_Open routine:

Application.CommandBars("Worksheet Menu
Bar").Controls("Navigation").Delete

When there is no "Navigation" control it seems to simply do nothing. I
realise this doesn't seem to be a programmatically sound approach - perhaps
others can comment.

Let me know if this works for you too.

Peter Morris
"Robin Clay" wrote in message
...
Greetings !

I have some routines in the "WorkbookOpen" routine
of various workbooks that create ToolBar buttons.

Generally, I have managed to get the relevant buttons
deleted when the workbook is closed, but what I haven't
yet
managed is to prevent new duplicate buttons being created.

Would SKS be so kind as to give me the relevant code ?

e.g.

Public Sub MakeButtons()

' Make "Print" button

If Exists Button(Print) Then ' <--- It's this line I
need help with !

Else
'Existing Make "Print" button routine goes here

End If


' Repeat for the other buttons


End Sub


RClay AT haswell DOT com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Duplicate ToolBar Buttons

Peter,

Deleting the toolbar this way is a sound approach. I wouldn't rely on
nothing happening though, it might be okay today but not tomorrow. I would
put error handling around it (see my response to OP) so that if it did fail,
the code will not bomb.

--

HTH

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

"Peter M" wrote in message
...
Robin

I have a similar problem and appear (only just tried this!) to have a
solution by adding the following line to my Workbook_Open routine:

Application.CommandBars("Worksheet Menu
Bar").Controls("Navigation").Delete

When there is no "Navigation" control it seems to simply do nothing. I
realise this doesn't seem to be a programmatically sound approach -

perhaps
others can comment.

Let me know if this works for you too.

Peter Morris
"Robin Clay" wrote in message
...
Greetings !

I have some routines in the "WorkbookOpen" routine
of various workbooks that create ToolBar buttons.

Generally, I have managed to get the relevant buttons
deleted when the workbook is closed, but what I haven't
yet
managed is to prevent new duplicate buttons being created.

Would SKS be so kind as to give me the relevant code ?

e.g.

Public Sub MakeButtons()

' Make "Print" button

If Exists Button(Print) Then ' <--- It's this line I
need help with !

Else
'Existing Make "Print" button routine goes here

End If


' Repeat for the other buttons


End Sub


RClay AT haswell DOT com





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Duplicate ToolBar Buttons

Robin,

You could put error handling around it

On Error Resuume Next
'your code to create button, this will fail but the resume next
'will stop it bombing out
'On Error Goto 0


--

HTH

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

"Robin Clay" wrote in message
...
Greetings !

I have some routines in the "WorkbookOpen" routine
of various workbooks that create ToolBar buttons.

Generally, I have managed to get the relevant buttons
deleted when the workbook is closed, but what I haven't
yet
managed is to prevent new duplicate buttons being created.

Would SKS be so kind as to give me the relevant code ?

e.g.

Public Sub MakeButtons()

' Make "Print" button

If Exists Button(Print) Then ' <--- It's this line I
need help with !

Else
'Existing Make "Print" button routine goes here

End If


' Repeat for the other buttons


End Sub


RClay AT haswell DOT com



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Duplicate ToolBar Buttons

Bob,

I think I should run my solutions passed you first!

A little more testing and my solution bombed out too! Inclusion of error
handling is a good idea!

Peter

"Bob Phillips" wrote in message
...
Robin,

You could put error handling around it

On Error Resuume Next
'your code to create button, this will fail but the resume next
'will stop it bombing out
'On Error Goto 0


--

HTH

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

"Robin Clay" wrote in message
...
Greetings !

I have some routines in the "WorkbookOpen" routine
of various workbooks that create ToolBar buttons.

Generally, I have managed to get the relevant buttons
deleted when the workbook is closed, but what I haven't
yet
managed is to prevent new duplicate buttons being created.

Would SKS be so kind as to give me the relevant code ?

e.g.

Public Sub MakeButtons()

' Make "Print" button

If Exists Button(Print) Then ' <--- It's this line I
need help with !

Else
'Existing Make "Print" button routine goes here

End If


' Repeat for the other buttons


End Sub


RClay AT haswell DOT com







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Duplicate ToolBar Buttons

Hello, Bob !

I had written:

Public Sub MakeButtons()
' Make "Print" button
If Exists Button(Print) Then
' <--- It's this line I need help with !
Else
'Existing Make "Print" button routine goes here
End If
' Repeat for the other buttons
End Sub



You kindly wrote,
You could put error handling around it

On Error Resuume Next
'your code to create button,
this will fail but the resume next
'will stop it bombing out
'On Error Goto 0


Erm... I don't get an error !

What I (sometimes) get is about six duplicate buttons !

However... maybe your reply to Peter M's kind response
(for which, many thanks) answers the case, i.e. delete the
button before creating it, and error-trap for the (usual)
case that the button does not already exist.

Thank you both !

But one more thing, if I may -
what does "On Error GoTo 0" do,
as opposed to "On Error Resume Next" ?


RClay AT haswell DOT com

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Duplicate ToolBar Buttons

About On Error GoTo 0.
From the Help:
On Error GoTo 0 disables error handling in the current procedure. It doesn't
specify line 0 as the start of the error-handling code, even if the
procedure contains a line numbered 0.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Robin Clay" wrote in message
...
Hello, Bob !

I had written:

Public Sub MakeButtons()
' Make "Print" button
If Exists Button(Print) Then
' <--- It's this line I need help with !
Else
'Existing Make "Print" button routine goes here
End If
' Repeat for the other buttons
End Sub



You kindly wrote,
You could put error handling around it

On Error Resuume Next
'your code to create button,
this will fail but the resume next
'will stop it bombing out
'On Error Goto 0


Erm... I don't get an error !

What I (sometimes) get is about six duplicate buttons !

However... maybe your reply to Peter M's kind response
(for which, many thanks) answers the case, i.e. delete the
button before creating it, and error-trap for the (usual)
case that the button does not already exist.

Thank you both !

But one more thing, if I may -
what does "On Error GoTo 0" do,
as opposed to "On Error Resume Next" ?


RClay AT haswell DOT com



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
Buttons in a toolbar Daddio_1962 Excel Discussion (Misc queries) 8 January 15th 08 04:50 AM
Toolbar buttons Liz Excel Discussion (Misc queries) 6 January 23rd 06 12:10 PM
Toolbar Buttons bmac Excel Discussion (Misc queries) 2 March 8th 05 11:05 PM
saving toolbar buttons on custom toolbar Paul James Excel Programming 12 August 6th 03 08:28 AM
Toolbar Buttons Bob Phillips[_5_] Excel Programming 0 August 5th 03 10:34 PM


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