Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
Hello,
I would like to lock my excel worksheet as soon as I loose focus. An exemple : Let's I'm puting values into my sheet and then I decide to write a word document. Once I clicked on "Start" (Programs-etc...), I want my excel to lock itself and then if I go back to my excel sheet I will be asked for a password. Is there a lost focus on worksheet method in excel vba ? Thanks in advance Nader PS : all this is to avoid to put in value by mistake in my excel sheet |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
Excel cannot you this directly as there is no Application_LostFocus event.
You will have use some API calls within a Timer to see if Excel is the ForeGround window. NickHK "Nader" wrote in message ... Hello, I would like to lock my excel worksheet as soon as I loose focus. An exemple : Let's I'm puting values into my sheet and then I decide to write a word document. Once I clicked on "Start" (Programs-etc...), I want my excel to lock itself and then if I go back to my excel sheet I will be asked for a password. Is there a lost focus on worksheet method in excel vba ? Thanks in advance Nader PS : all this is to avoid to put in value by mistake in my excel sheet |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
But can I use a Timer inside excel vba to lock my excel sheet if a user do
not enter a value after 20 seconds ? "NickHK" a écrit dans le message de news: ... Excel cannot you this directly as there is no Application_LostFocus event. You will have use some API calls within a Timer to see if Excel is the ForeGround window. NickHK "Nader" wrote in message ... Hello, I would like to lock my excel worksheet as soon as I loose focus. An exemple : Let's I'm puting values into my sheet and then I decide to write a word document. Once I clicked on "Start" (Programs-etc...), I want my excel to lock itself and then if I go back to my excel sheet I will be asked for a password. Is there a lost focus on worksheet method in excel vba ? Thanks in advance Nader PS : all this is to avoid to put in value by mistake in my excel sheet |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
Check out
http://www.cpearson.com/excel/ontime.htm NickHK "Nader" wrote in message ... But can I use a Timer inside excel vba to lock my excel sheet if a user do not enter a value after 20 seconds ? "NickHK" a écrit dans le message de news: ... Excel cannot you this directly as there is no Application_LostFocus event. You will have use some API calls within a Timer to see if Excel is the ForeGround window. NickHK "Nader" wrote in message ... Hello, I would like to lock my excel worksheet as soon as I loose focus. An exemple : Let's I'm puting values into my sheet and then I decide to write a word document. Once I clicked on "Start" (Programs-etc...), I want my excel to lock itself and then if I go back to my excel sheet I will be asked for a password. Is there a lost focus on worksheet method in excel vba ? Thanks in advance Nader PS : all this is to avoid to put in value by mistake in my excel sheet |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
Nader,
Not what you originally asked for but may be an acceptable 'simple' solution for you... PS : all this is to avoid to put in value by mistake in my excel sheet Try putting the following procedure in your worksheet code module. It will mean hitting Return twice for every legitimate entry but may be an acceptable overhead to avoid an accidental entry... Private Sub Worksheet_Change(ByVal Target As Range) Dim Response As Variant Dim msg As String Dim Title As String msg = Target.Range("A1").Address & " = '" & Target.Range("A1").Value & "'" msg = msg & vbCrLf & vbCrLf msg = msg & "Accept entry?" Title = "Confirm Entry" Response = MsgBox(msg, vbYesNo + vbQuestion, Title) If Response = vbNo Then With Application .EnableEvents = False .Undo .EnableEvents = True End With End If End Sub Kind regards, NickH |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
Oops, beware the wrap-around:
Target.Range("A1").Value & "'" belongs on the end of the preceding line. Nick H |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
lock excel worksheet when loosing focus
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loosing data in shared worksheet. | Excel Worksheet Functions | |||
how do I lock only a few cells in Excel within a worksheet? | Excel Worksheet Functions | |||
lock rows and columns on a web Excel worksheet. | Excel Discussion (Misc queries) | |||
Excel crashes everytime I send focus from control to worksheet | Excel Programming | |||
How to Lock the selected cells in Excel worksheet | New Users to Excel |