Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Reset VB Code Not Working on Close

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reset VB Code Not Working on Close

Your previous posting of this question was answered.

--
Regards,
Tom Ogilvy


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Reset VB Code Not Working on Close

Give this a try. It also removes the insert from the right click menu of the
tabs...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Del ete
CommandBars("Ply").Controls("Insert...").Delete
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu bar").Reset
CommandBars("Ply").Reset
End Sub

That being said your users could still insert a sheet using Shift + F11...
--
HTH...

Jim Thomlinson


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reset VB Code Not Working on Close

Just a thought, but I suspect they would also be pretty upset that you
destroyed their menu customizations by using the ill advised RESET approach.

--
Regards,
Tom Ogilvy


"Jim Thomlinson" wrote:

Give this a try. It also removes the insert from the right click menu of the
tabs...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Del ete
CommandBars("Ply").Controls("Insert...").Delete
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu bar").Reset
CommandBars("Ply").Reset
End Sub

That being said your users could still insert a sheet using Shift + F11...
--
HTH...

Jim Thomlinson


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default Reset VB Code Not Working on Close

Very good point. I tried your suggestion and get the following error message:
Procedure declaration does not match description of event or procedure
having the same name.

I want the users to add worksheets using the EditMove or CopyCreate copy
so the file properties and formatting of the first worksheet continues to all
subsequent worksheets (in some cases there will be hundreds of worksheets).

"Tom Ogilvy" wrote:

Just a thought, but I suspect they would also be pretty upset that you
destroyed their menu customizations by using the ill advised RESET approach.

--
Regards,
Tom Ogilvy


"Jim Thomlinson" wrote:

Give this a try. It also removes the insert from the right click menu of the
tabs...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Del ete
CommandBars("Ply").Controls("Insert...").Delete
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu bar").Reset
CommandBars("Ply").Reset
End Sub

That being said your users could still insert a sheet using Shift + F11...
--
HTH...

Jim Thomlinson


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reset VB Code Not Working on Close

Private Sub Workbook_BeforeClose(Cancel As Boolean)

End Sub
is the actual declaration. You should always get the declaration by using
the dropdowns at the top of the module to make sure you are a) in the right
module, b) use the correct declaration.

I wasn't providing a turn key approach, just a recommendation on what events
to use by using some pseudo code.

--
Regards,
Tom Ogilvy


"Jane" wrote:

Very good point. I tried your suggestion and get the following error message:
Procedure declaration does not match description of event or procedure
having the same name.

I want the users to add worksheets using the EditMove or CopyCreate copy
so the file properties and formatting of the first worksheet continues to all
subsequent worksheets (in some cases there will be hundreds of worksheets).

"Tom Ogilvy" wrote:

Just a thought, but I suspect they would also be pretty upset that you
destroyed their menu customizations by using the ill advised RESET approach.

--
Regards,
Tom Ogilvy


"Jim Thomlinson" wrote:

Give this a try. It also removes the insert from the right click menu of the
tabs...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Del ete
CommandBars("Ply").Controls("Insert...").Delete
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu bar").Reset
CommandBars("Ply").Reset
End Sub

That being said your users could still insert a sheet using Shift + F11...
--
HTH...

Jim Thomlinson


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Reset VB Code Not Working on Close

I considered that but I figured if Jane wants a reset then who am I to argue.
I should have included a "careful what you wish for" section in my response,
or done what you did...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Vis ible = False
CommandBars("Ply").Controls("Insert...").Visible = False
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Vis ible = True
CommandBars("Ply").Controls("Insert...").Visible = True
End Sub

I should be a little more careful with my replies especially on a monday
morning before I have finished my first cup of coffee :-)
--
HTH...

Jim Thomlinson


"Tom Ogilvy" wrote:

Just a thought, but I suspect they would also be pretty upset that you
destroyed their menu customizations by using the ill advised RESET approach.

--
Regards,
Tom Ogilvy


"Jim Thomlinson" wrote:

Give this a try. It also removes the insert from the right click menu of the
tabs...

Sub menuItem_Delete()
CommandBars("Worksheet menu
bar").Controls("Insert").Controls("Worksheet").Del ete
CommandBars("Ply").Controls("Insert...").Delete
End Sub

Sub MenuBar_Restore()
CommandBars("Worksheet menu bar").Reset
CommandBars("Ply").Reset
End Sub

That being said your users could still insert a sheet using Shift + F11...
--
HTH...

Jim Thomlinson


"Jane" wrote:

New to VB. Want to remove the Insert Worksheet option on open and Reset at
close. Using this code:

Module 1:
Sub menuItem_Delete()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Insert")
myCmd.Controls("Worksheet").Delete
End Sub

Module 2:
Sub MenuBar_Restore()
CommandBars("Insert").Reset
End Sub

Can't get Module 2 to work on close. Any help is greatly appreciated.

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
Reset button code for Radio Buttons [email protected] Excel Discussion (Misc queries) 6 August 25th 12 03:09 PM
Delete Insert Worksheet on Open/Reset on Close Jane Excel Programming 1 April 10th 06 02:08 PM
Master reset code bug - stumped again peter.thompson[_28_] Excel Programming 1 January 7th 06 07:38 AM
Master reset code -stumped peter.thompson[_24_] Excel Programming 6 January 7th 06 01:35 AM
How do I reset the LastUsed cell reference from code. Henry[_4_] Excel Programming 2 October 12th 03 09:34 PM


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