Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Unable to disable macro

Hi, I have created a macro in a worksheet, to disable the menu toolbars etc.
I had also protected the sheet (which I've since removed).

The *very* frustrating problem is, any other workbook I open now (either new
or existing) prevents me from rightclicking on the mouse to insert rows
columns etc.

I am presuming it is something to do with the macro I created, which looks
like as below, but I want to switch everything off and return back to normal
Excel operation when this workbook is closed. Can anyone point me in the
right direction - perhaps its an excel option somewhere I simply need to
switch off?

Option Explicit

Private mFormulaBar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Hi,

You shoud add the following instruction :
Cancel = True
in your workbook_beforeclose macro

HTH
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Hi Lisa,

In these instances, you must make sure you are reversing all your
initial instructions ...
It looks like you are missing :

Application.DisplayFormulaBar = True

HTH
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

....
It could also that you need to replicate all your "back-to-normal"
instructions in a
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) macro

HTH
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Unable to disable macro

Hi Carim

Thanks for getting back to me. I've added in your suggestions, but I still
cant use right click on the mouse for anything.

On you last suggestion, I added the Private Sub
Workbook_WindowDeactivate(ByVal Wn As Window) but this was only recognised
when I trimmed the statement to Private Sub Workbook_WindowDeactivate

"Carim" wrote:

....
It could also that you need to replicate all your "back-to-normal"
instructions in a
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window) macro

HTH



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Hi Lisa,

Have a go with :

Sub Test()
Application.CommandBars("Cell").Enabled = True
End Sub

HTH
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Unable to disable macro

Hi

Still no joy on this

"Carim" wrote:

Hi Lisa,

Have a go with :

Sub Test()
Application.CommandBars("Cell").Enabled = True
End Sub

HTH

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Lisa,

Obviously this incident was generated by another macro ..

Hope this one will fix your problem ...

Sub Test()
Application.CommandBars("Cell").Reset
End Sub

HTH
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Unable to disable macro

Still no joy Grr lol!

I've made a discovery which means I can offer some further information.

When I go into the Visual Basic part, I have the following under 'This
Workbook'

Private Sub Workbook_Open()
'Application.DisplayFullScreen = True
Application.CommandBars("Worksheet Menu Bar").Enabled = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayFullScreen = False
Application.CommandBars("Worksheet Menu Bar").Enabled = True
End Sub

Then under the Modules Section, I have 3 modules - 1 and 3 are empty (!) and
Module 2 contains the following (which is what I have been tweaking with your
suggestions)

Option Explicit

Private mFormulaBar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB
Cancel = True

Application.DisplayFormulaBar = mFormulaBar
Application.CommandBars("Cell").Enabled = True

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub

I must admit, I'm not sure whether the primary code should reside under
'This Workbook' or within a module - surely I should consolidate these into
the correct place also?

Thanks

"Carim" wrote:

Lisa,

Obviously this incident was generated by another macro ..

Hope this one will fix your problem ...

Sub Test()
Application.CommandBars("Cell").Reset
End Sub

HTH

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Unable to disable macro

Yippee!

Cracked it. I placed your suggestion of
Application.CommandBars("Cell").Enabled = True as the first line within the
Before_Close routing

Thanks for all of your help :-)

"Lisa" wrote:

Still no joy Grr lol!

I've made a discovery which means I can offer some further information.

When I go into the Visual Basic part, I have the following under 'This
Workbook'

Private Sub Workbook_Open()
'Application.DisplayFullScreen = True
Application.CommandBars("Worksheet Menu Bar").Enabled = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayFullScreen = False
Application.CommandBars("Worksheet Menu Bar").Enabled = True
End Sub

Then under the Modules Section, I have 3 modules - 1 and 3 are empty (!) and
Module 2 contains the following (which is what I have been tweaking with your
suggestions)

Option Explicit

Private mFormulaBar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB
Cancel = True

Application.DisplayFormulaBar = mFormulaBar
Application.CommandBars("Cell").Enabled = True

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
End Sub

I must admit, I'm not sure whether the primary code should reside under
'This Workbook' or within a module - surely I should consolidate these into
the correct place also?

Thanks

"Carim" wrote:

Lisa,

Obviously this incident was generated by another macro ..

Hope this one will fix your problem ...

Sub Test()
Application.CommandBars("Cell").Reset
End Sub

HTH



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Lisa,

I am guessing all your problems are coming from your private
toolbar ..

Take a look at Ron's solution :
http://groups.google.com/group/micro...110ddeb0d1a906

HTH
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Unable to disable macro

Lisa,

Glad you managed to fix your problem ...

Thanks for the feedback
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
Disable running of SelectionChange macro when in another macro? Tonso Excel Discussion (Misc queries) 6 March 21st 10 06:50 PM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
unable to record macro Denis[_4_] Excel Programming 0 June 29th 06 05:21 PM
Unable to run Macro in an Add-in [email protected] Excel Worksheet Functions 0 January 23rd 06 07:18 PM
Disable Macro at open by an external macro Ricardo[_2_] Excel Programming 0 November 10th 03 07:50 PM


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