How to disable warning on doubleclick

Gringoire

Board Regular
Joined
Nov 18, 2016
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Dear Gentlemen,
I'm using the doubleclick event to trig a procedure on a protected Sheet. I would like to avoid the warning message that appears when the user double click on a Cell.
I used this code but it does not work.
Could you please show mw where I'm wrong?

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As Boolean)
With Application
    .DisplayAlerts = False
    .AlertBeforeOverwriting = False
    .ScreenUpdating = False
End With
...
'here is my procedure
...
With Application
    .DisplayAlerts = True
    .AlertBeforeOverwriting = True
    .ScreenUpdating = True
End With
End Sub

thanks.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
What is the warning message ?
If it is a warning about a protected sheet...you will have to incorprate the sheet UnProtect in your code then Reprotect at the end of the code !

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As Boolean)
With Application
    .DisplayAlerts = False
    .AlertBeforeOverwriting = False
    .ScreenUpdating = False
End With
 Worksheets("Sheet1").Unprotect
'here is my procedure
Worksheets("Sheet1").Protect..
With Application
    .DisplayAlerts = True
    .AlertBeforeOverwriting = True
    .ScreenUpdating = True
End With
End Sub
 
Upvote 0
[EDIT]: If this could help, I noticed that the warning appears after the End Sub instruction is executed.
 
Upvote 0
What is the warning message ?
If it is a warning about a protected sheet...
Yes, it is.

you will have to incorprate the sheet UnProtect in your code then Reprotect at the end of the code !
Yes I did it just now, but the message still appears.
It seems like the warning message is triggered after the BeforeDoubleClick event is completed...
 
Upvote 0
You could try using in the workbook open event
VBA Code:
Private Sub Workbook_Open()
Worksheets("Sheet1").Protect password:="PASSWORD", UserInterfaceOnly:=True
End Sub
The see if the double click event works
 
Upvote 0
Thanks for your help Michael, but I already implemented such a procedure in workbook_open() from the beginning of my project.
this is the Sub called by workbook_open()

VBA Code:
Sub Protezione(Cartella As Worksheet, stato As Boolean)
'=============================
' Protegge / sprotegge un foglio Excel
'=============================
Dim PWD As String
Dim dummy As Long

PWD = "xxx"
If stato = True Then                            'Proteggo il foglio
Cartella.Protect Password:=PWD, _
    DrawingObjects:=True, _
    Contents:=True, _
    Scenarios:=True, _
    UserInterfaceOnly:=True, _            '<=======
    AllowFormattingCells:=False, _
    AllowFormattingColumns:=False, _
    AllowFormattingRows:=False, _
    AllowInsertingColumns:=False, _
    AllowInsertingRows:=False, _
    AllowInsertingHyperlinks:=False, _
    AllowDeletingColumns:=False, _
    AllowDeletingRows:=False, _
    AllowSorting:=False, _
    AllowFiltering:=False, _
    AllowUsingPivotTables:=False
ElseIf stato = False Then                       'Sproteggo il foglio
    Cartella.Unprotect (PWD)
Else
    dummy = MsgBox("Errore protezione foglio")
End If
End Sub
 
Upvote 0
For information: I solved this issue adding the following instruction just before the End Sub statement, when myprocedure is already completed.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As Boolean)
...
'myprocedure
...
If target.Locked Then Cancel = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top