PC Review


Reply
Thread Tools Rate Thread

Disable Worksheet_SelectionChange macros

 
 
=?Utf-8?B?Q0xS?=
Guest
Posts: n/a
 
      14th Nov 2007
Hi All.........
I am trying to disable all change-event macros (or even ALL macros) upon
opening a second workbook, with my code in the first workbook so the first
workbooks macros will function without any interference from the second
workbook macros.

I've tried

Application.EnableEvents = False
workbook.open

and tried

Sec = Application.AutomationSecurity
Application.EnableEvents = False
Application.AutomationSecurity = msoAutomationSecurityForceDisable
workbook.open

both seem to work, but when I then use a line like

Activesheet.UsedRange.SpecialCells(xlCellTypeFormulas, 23).Count

It starts to run the "Private Sub Worksheet_SelectionChange(ByVal Target As
Excel.Range)" macro for the Sheet in the second workbook that is active.

I would like it to NOT do that.

Any assistance would be much appreciated.

Vaya con Dios,
Chuck, CABGx3


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      14th Nov 2007
Not sure if it helps but disabling events is an application level setting. So
if you disable the events in workbook 1 then no events will fire in either
workbook. Just make darn sure you switch the events back on when you are done

Application.enableEvents = false
Activesheet.UsedRange.SpecialCells(xlCellTypeFormulas, 23).Count
applicaiton.enableevents = true
--
HTH...

Jim Thomlinson


"CLR" wrote:

> Hi All.........
> I am trying to disable all change-event macros (or even ALL macros) upon
> opening a second workbook, with my code in the first workbook so the first
> workbooks macros will function without any interference from the second
> workbook macros.
>
> I've tried
>
> Application.EnableEvents = False
> workbook.open
>
> and tried
>
> Sec = Application.AutomationSecurity
> Application.EnableEvents = False
> Application.AutomationSecurity = msoAutomationSecurityForceDisable
> workbook.open
>
> both seem to work, but when I then use a line like
>
> Activesheet.UsedRange.SpecialCells(xlCellTypeFormulas, 23).Count
>
> It starts to run the "Private Sub Worksheet_SelectionChange(ByVal Target As
> Excel.Range)" macro for the Sheet in the second workbook that is active.
>
> I would like it to NOT do that.
>
> Any assistance would be much appreciated.
>
> Vaya con Dios,
> Chuck, CABGx3
>
>

 
Reply With Quote
 
=?Utf-8?B?Q0xS?=
Guest
Posts: n/a
 
      14th Nov 2007
Thanks Jim, for both the response, and the important information. All is
well now in my little world......it works fine.

The solution is not in just having the right answer, but in it's proper
application.

Thanks again,
Vaya con Dios,
Chuck, CABGx3






"Jim Thomlinson" wrote:

> Not sure if it helps but disabling events is an application level setting. So
> if you disable the events in workbook 1 then no events will fire in either
> workbook. Just make darn sure you switch the events back on when you are done
>
> Application.enableEvents = false
> Activesheet.UsedRange.SpecialCells(xlCellTypeFormulas, 23).Count
> applicaiton.enableevents = true
> --
> HTH...
>
> Jim Thomlinson
>
>
> "CLR" wrote:
>
> > Hi All.........
> > I am trying to disable all change-event macros (or even ALL macros) upon
> > opening a second workbook, with my code in the first workbook so the first
> > workbooks macros will function without any interference from the second
> > workbook macros.
> >
> > I've tried
> >
> > Application.EnableEvents = False
> > workbook.open
> >
> > and tried
> >
> > Sec = Application.AutomationSecurity
> > Application.EnableEvents = False
> > Application.AutomationSecurity = msoAutomationSecurityForceDisable
> > workbook.open
> >
> > both seem to work, but when I then use a line like
> >
> > Activesheet.UsedRange.SpecialCells(xlCellTypeFormulas, 23).Count
> >
> > It starts to run the "Private Sub Worksheet_SelectionChange(ByVal Target As
> > Excel.Range)" macro for the Sheet in the second workbook that is active.
> >
> > I would like it to NOT do that.
> >
> > Any assistance would be much appreciated.
> >
> > Vaya con Dios,
> > Chuck, CABGx3
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word & Enable Macros and Disable macros Theresa Microsoft Word Document Management 1 29th Sep 2008 10:38 PM
"openinf file..."ENABLE MACROS...DISABLE MACROS" =?Utf-8?B?Ri4gTGF3cmVuY2UgS3VsY2hhcg==?= Microsoft Excel Misc 3 12th Sep 2006 10:33 AM
Removing Excel message to enable macros or disable macros =?Utf-8?B?Ym1pbGxlcjI2Mw==?= Microsoft Excel Misc 2 13th Oct 2004 02:39 PM
Doc has no macros, but I'm prompted to enable/disable macros Microsoft Word Document Management 2 7th Oct 2004 09:34 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Microsoft Excel Programming 5 24th Sep 2003 03:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:22 PM.