PC Review


Reply
Thread Tools Rate Thread

Application.DisplayAlerts = False does not disable alerts

 
 
Derek Dowle
Guest
Posts: n/a
 
      9th Dec 2009
The code ‘Application.DisplayAlerts = False’ does not work in all instances.

I have two virtually identical worksheets in different workbooks.

These worksheets act as an index and each cell is protected. By
double-clicking on a particular cell my VBA code gathers some data and
completes a procedure. The ‘Application.DisplayAlerts = False’ should
prevent the protection alert from appearing.

In the first workbook it works. The code was placed in ‘Private Sub
Worksheet_Activate()’. It did not work if it was placed at the beginning of
code in ‘Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
Cancel As Boolean)’.

Place the same code in the second workbook and it does not work.

I have also opened a new workbook. Sheet1 has been protected and the
‘Application.DisplayAlerts = False’ code placed in ‘Private Sub
Worksheet_Activate()’. If I DoubleClick the protect alert appears.

Is there a way around this problem?

The only thing that has changed since the first book was created is that
Vista Business Version 6.0.6002 Service Pack 2 Build 6002 has been installed.

Excel version used is Excel 2003.

--
Derek Dowle
 
Reply With Quote
 
 
 
 
Ryan H
Guest
Posts: n/a
 
      9th Dec 2009
It sounds like the default action for the double click event is firing. Its
trying to enter into a cell to edit it, but the sheet is protected so you get
the alert. Set Cancel = True in the BeforeDoubleClick event, like below.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Cancel = True
Application.DisplayAlerts = True

' rest of your code here

End Sub

Hope this helps! If so, let me know, click 'YES' below.
--
Cheers,
Ryan


"Derek Dowle" wrote:

> The code ‘Application.DisplayAlerts = False’ does not work in all instances.
>
> I have two virtually identical worksheets in different workbooks.
>
> These worksheets act as an index and each cell is protected. By
> double-clicking on a particular cell my VBA code gathers some data and
> completes a procedure. The ‘Application.DisplayAlerts = False’ should
> prevent the protection alert from appearing.
>
> In the first workbook it works. The code was placed in ‘Private Sub
> Worksheet_Activate()’. It did not work if it was placed at the beginning of
> code in ‘Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
> Cancel As Boolean)’.
>
> Place the same code in the second workbook and it does not work.
>
> I have also opened a new workbook. Sheet1 has been protected and the
> ‘Application.DisplayAlerts = False’ code placed in ‘Private Sub
> Worksheet_Activate()’. If I DoubleClick the protect alert appears.
>
> Is there a way around this problem?
>
> The only thing that has changed since the first book was created is that
> Vista Business Version 6.0.6002 Service Pack 2 Build 6002 has been installed.
>
> Excel version used is Excel 2003.
>
> --
> Derek Dowle

 
Reply With Quote
 
Ryan H
Guest
Posts: n/a
 
      9th Dec 2009
Or you may need unprotect the sheet at the beginning of your code so you
don't get any errors writing to the sheet and then reprotect the sheet at the
end of your code. Like so,

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Cancel = True
Application.DisplayAlerts = True

ActiveSheet.Unprotect "password"

' rest of your code here

ActiveSheet.Protect "password"
Application.DisplayAlerts = False

End Sub

Hope this helps! If so, let me know. Click "YES" below.
--
Cheers,
Ryan


"Derek Dowle" wrote:

> The code ‘Application.DisplayAlerts = False’ does not work in all instances.
>
> I have two virtually identical worksheets in different workbooks.
>
> These worksheets act as an index and each cell is protected. By
> double-clicking on a particular cell my VBA code gathers some data and
> completes a procedure. The ‘Application.DisplayAlerts = False’ should
> prevent the protection alert from appearing.
>
> In the first workbook it works. The code was placed in ‘Private Sub
> Worksheet_Activate()’. It did not work if it was placed at the beginning of
> code in ‘Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range,
> Cancel As Boolean)’.
>
> Place the same code in the second workbook and it does not work.
>
> I have also opened a new workbook. Sheet1 has been protected and the
> ‘Application.DisplayAlerts = False’ code placed in ‘Private Sub
> Worksheet_Activate()’. If I DoubleClick the protect alert appears.
>
> Is there a way around this problem?
>
> The only thing that has changed since the first book was created is that
> Vista Business Version 6.0.6002 Service Pack 2 Build 6002 has been installed.
>
> Excel version used is Excel 2003.
>
> --
> Derek Dowle

 
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
'Save as' dialog opens despite Application.DisplayAlerts = False Poniente Microsoft Excel Programming 4 26th Jun 2011 09:43 AM
Application.DisplayAlerts = False Jim May Microsoft Excel Programming 10 18th Aug 2006 05:32 PM
Application.DisplayAlerts = False - Not Working carusoloredana@gmail.com Microsoft Excel Programming 3 1st Mar 2006 08:39 PM
MS Excel -- Application.DisplayAlerts=False =?Utf-8?B?UnViYmxl?= Microsoft Access 2 18th Nov 2005 01:51 AM
Application.DisplayAlerts = False - why doesn't it work? kenji4861 Microsoft Excel Misc 0 25th Feb 2004 05:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:49 AM.