Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Lock/Unlock Macro

I have a few macros that only should be run once a day. Does anyone know how to lock a macro button after its been run and unlock it when the sheet gets open again.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Lock/Unlock Mouse...Lock/Unlock Keyboard????
Any body have the code to Lock/Unlock Mouse and Lock/Unlock Keyboard..
and on all areas..not just on the form area..If you know what i mean..

To Lock Or Unlock
Does anyone know how to detect if a table is locked during run time? If so, can it be unlocked once detected?

This would be done via Jet 4.0, ADO 2.6 and Access 97 DB backend.

I await your comments.


Lock And Unlock COntrols In VBA
Hi All

In VB it is possible to lock and unlock controls. I was also expecting that this would be possible in VBA, however I have not been able to find this feature. Maybe I'm not looking in the right place. I have looked at all the menus and have not been able to find this feature.

I would appreciate any information that you can provide for me.

Kind Regards

Lock / Unlock A Cd-rom Drive
i swear i've seen this before, but i can't fint it.

how to lock / unlock access to a cd-rom drive? the same way a burning program does.

a timer that closes the door is NOT the answer

How Can I Lock/Unlock The Clipboard!!?
Hi..I was wondering how can i lock the clipboard!
I can use that code in a timer(Interval=1):
Bu i don't want the content of the clipboard to be deleted...
any other suggestions?

How To Lock And Unlock Listview?
How do I lock and unlock ListView such that I can control when the user can edit the ListView?

HOw Lock And Unlock CTRL + Alt + Del
HOw lock and unlock CTRL + alt + del,alt + tab,Button Windows in windows XP

Using VB Lock/Unlock Computer
I want to know which api to use for Lock Unlock Computer
and even How to SENCE that computer is in LOCK mode (that we can do in XP by pressing ctrl+Alt+Del buttons.

Can u Please Help me to find Solution with this.

Lock/Unlock Table
Hi all,
I have a program that if the users presses one button a certain table is opened and a temp table is created. If another button is pressed, a different table is opened and the temp table is dropped and recreated. Below is the code used to create a temp table and make a connection. My problem is that the user presses the button, the temp table is made, a connection is made and all works fine. Then if the user presses the other button, the program gives me an error message that the temnumber table is locked and cannot be dropped while in use. How can I unlock the table to drop it.
Thanks for any and all help

numtempcn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:lotterydatagame.mdb"
numtempcn.Execute "Drop Table tempnumber"
numtempcn.Execute "CREATE TABLE tempnumber (number1 integer,hit1 integer,number2 integer, hit2 integer, number3 integer, hit3 integer, number4 integer, hit4 integer, number5 integer, hit5 integer,number6 integer, hit6 integer)"
rsnumtemp.CursorType = adOpenDynamic
rsnumtemp.LockType = adLockOptimistic
rsnumtemp.CursorLocation = adUseClient
rsnumtemp.Open numsql, numtempcn, adOpenDynamic, adLockOptimistic

Lock And Unlock Folder ..(quite Urgent)..
Hi friends,

In my visulabasic project , i need to lock and unlock one folder , how to do this one??
any idea??

advance thanks for your help..

waiting for your valuable information..

with regards,

Lock/unlock All Text Fields
may i know how to lock and unlock all text fields in a form for vb? thanks.

Trap For Workstation Lock/Unlock
How can I trap for when a user locks or unlocks their workstation in either NT4 of 2K?
I know how to trap for the shutdow or re-boots, but thats it.

Thanks for any assistance in advance.

Lock Or Unlock Slave Computer...
<html><div style='background-color:'><DIV></DIV>
<DIV>Help me please,</DIV>
<DIV>I need lock or unlock in a network one computer with other computer, any idea please ?</DIV>
<DIV> </DIV>
<DIV>Thanks a lot</DIV>
<DIV>Fernando Oviedo</DIV></div><br clear=all><hr>Protect your PC - <a href="">Click here</a> for VirusScan Online </html>

How To Lock / Unlock Floppy Disk ?
How to Lock / Unlock Floppy Disk programatically?
I want to take counter while installing my software throught CD. And at the same time counter will generated on floppy drive.

Lock/unlock Computer In Win2000
Anybody knows how to programatically lock and unlock computer running under WIN2000 with VB and locking it from a server terminal?
Just like pressing ctrl+alt+del and clicking on lock computer.

How Can I Unlock The DataGrid Lock Property (Runtime)
Suppose I locked the DataGrid in Custom - Layout Property at design time.
How can I unlock it Runtime.

Even at design time it, suppose you lock at run it, It will not update the
records into Grid.


Supose I run the following code after unlocking the data grid (at design
time). We can see the all the effect of the
Caption, columns heading, but the datagrid will be empty

sql = "select code, cable_id from mst_cid"
SetRsMast sql, temprsHelp
If Not temprsHelp.EOF Then
Set dgHelp5.DataSource = temprsHelp
dgHelp5.ColumnHeaders = True
dgHelp5.Columns(0).Caption = "Code"
dgHelp5.Columns(1).Caption = "Name"
dgHelp5.Columns(0).Width = 800
dgHelp5.Columns(1).Width = dgHelp5.Width - 200
End If

Detect Logoff/logon/lock/unlock Workstation Events
I need to write a utility that will perform a function on another
running program depending upon the user logging off/on or
locking /unlocking the workstation. How can I detect these

Any help is greatly appreciated.

Lock That Macro!
Hello all! I have a problem. I have an Excel spreatsheet with a macro that enters the date and time into a cell when a checkbox is checked. The macro uses the "NOW()" function which works fine except for one thing. Each time I open the sheet, the date and time updates to the current. I need the date and time to remain at the values displayed when the checkbox is checked. Is there a way to 'lock' the macro? Any help would be much appreciated. Thanks and have a good day!

I Want To Write An Excel Macro That Will Lock The
file after a certain date.

ie if date is greater than mm/dd/yyyy
then save with a password and close the file.

can someone help?

Excel Macro Within VB Causing File Lock Problem
The macro within the following code segment (apparently) causes a file locking and a contention issue. After running the program and this subroutine executing, when I try to open the resulting excel file, excel hangs. If I quit my program after it executes, then I can open the file. If I comment out the macro part, no problems also. Any ideas?

Private Sub cmdInvoice_Click()

'declare and start a new excel application
Dim MyXLApp As Excel.Application
Set MyXLApp = New Excel.Application
'Open an Excel workbook
MyXLApp.Workbooks.Open FileName:="C:Test Invoice.xls"
Row = 10


query = "select ...."
Set DataSet = New ADODB.Recordset
DataSet.Open query, connDB, adOpenStatic, adLockReadOnly

Do Until DataSet.EOF

MyXLApp.Cells(Row, 1) = DataSet("date")
MyXLApp.Cells(Row, 2) = DataSet("year")

.... and so on

MyXLApp.Cells(Row, 5).Select
With ActiveCell.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=12, Length:=6).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Row = Row + 1


'free up your memory
Set MyXLApp = Nothing

End Sub

Detect Num Lock Caps Lock And Scroll Lock &lt;solved&gt;
i am creating a small password username program and the password is case sensitive and i want it to be but i want to warn the user if the caps lock or num lock or scroll lock is on, though i do not know to detect if these are on , anyone know thanks!.

Best Reguards

Dave Barr

Edited by - crazyoldman on 1/11/2006 11:38:51 AM

Num Lock, Scroll Lock && Caps Lock QUestion
How can i activate the Num Lock, Scroll Lock & Caps Lock using vb?

Lock Shift/Caps Lock Keys
Does anybody know how to temporarily disable the use of the shift and caps lock keys to change case?
And how to detect the status of the caps lock?

Shift Lock Or Caps Lock Key Control
Is it possible to control the Shift Lock key whenever a field got the focus.

I want the user to type capital letters even if the Shift Lock or Caps lock key isn't presed.

I can after the typing use UCASE(field) but want to show the capitals immeditate on my form.

Unlock Key
Hi All

Is it possible to embed a value into to an unlock key which is created using a keygen. What i want to do is have an option to select a number of days(i.e 30 days) in the keygen and when u create the key it incoporates that value in the key. The reason i want to do this is when the user uses the key to register the app that i have developed then i want my app to check the key for that value and input it into my app , so the user will only be able to use the app for 30 days which i have specified in the unlock key using the keygen, and then when the app reaches the 30 day limit then he would have to apply for another key.

Can this be done.

Im am using a program called active lock.

Unlock For Editing
Visual Basic 6.0 w/Excel

I was sent a spreadsheet that contains a macro. When I open the spreadsheet, I am greeted with the Enable or Disable Macro buttons. I selected the Enable button. I was curious to see the VB code for this macro, but when select Tools, Macros and select the macro, the Edit button is disabled. Is there any way to allow edit. That's the only way to look at the code.


Unlock Pc From Sleep
Does anyone know how to unlock the pc from sleep? or how to make a computer so it won't become ideal and the screen saver won't come on? In my pc i have 15 min window. there is no way I could change this. even through the registry. I am trying to sehedule a script to run over night but since the computer locks up after 15 min of ideal time the script fails to run. Please HELP

Unlock Records
i am developing a VB6 application connecting to ORACLE 8.0. database. i have a question, how can i unlock a record without disconnecting?

the problem is like this. i make a connection to the database when the user start the app. when the user open a form, i lock a certain record so others won't be able to change the record by using "SELECT .... FOR UPDATE". so if the user opened more than 1 forms, i would have lock a few records using the same connection. when the user exit a form, i would like to unlock the record that was previously locked by this form without unlocking the other records.

Are there anyway i can do this without disconnecting or issuing a BeginTrans/RollbackTrans? thanks

To Unlock The PDF For Copying
 i have pdf file which is locked as result when i am trying copy and paste into other applications like MSWord or Notepad its not copying as such instead its copying as jumble charecters.I need to unlock the pdf file and should be able to copy the content of it into other application Using VB.

Need Some Code To Unlock My Pc...
I have a script that runs overnight and uses screen-scraping. It only works when my pc is unlocked. I want to run another script a couple minutes before it to unlock my pc and my policies will lock it back afterwards.

Please help. Thanks.

How To Unlock A Project
I have an old project that I loaded up again today. I forgot that some
components on the form requires license files. As a result, after I open the
project, the project is read only (locked by VB, not by the file system).

Now I have found an older version of license file which is not compatible
with the newer controls. I want to simply remove the newer versions of the
control from the form, and replace them with an older version. However,
since the project is read only, I am unable to do that.

Any idea?

Thanks in advance

File Lock Or Folder Lock
Is there any api i can use to lock files or folder, preventing them to be accessible from the user???

i tried to open the file without any sharing, it works alright, but it would be a little slow if i want to lock a folder with many many files in it...

How To Unlock Record Or File
Hi Folks,

I hope you all would be doing great. Just like at the weddings' day :d lolz.

Here's my problem. I have a database application developed in VB6. I want to prevent a record being edit at the same time by multiple users. The Database which i am using uses tables as datafiles which are directly stored on disk. But if one user has already opened that record and is focusing on that, my application cannot access that and i get an error , "that file or record may be in use". Is there any way i can unlock that record for the time being and make changes than save the current record.? or can i unlock or set permissions of that file so i can edit that record ? database i am using is known as advantage database which is i am sure unknown to people around here. Kindly help me i am under a REALLY DEADLINE ..

seeking help from experts...

How 2 Unlock VBAProject - No Pwd Prompt?

newbie question...

I'm trying to unlock a VABProject - but when I click on it or get properties there is no password prompt so I can't unlock it - it just pops up a message saying the project locked/unviewable.

where/how do I enter the password to unlock it!?


Unlock A Locked File?
I have a large (in GB) Access database. I need to compact/repair it regularly. What I do: create a copy of the database and compact/repair the copy. I want to delete the original and rename the copy to the original name.

In VB6, you can simply rename an executable and then delete it (to delete a running EXE).

Can something like this be done in Access?

Unlock An Excel Spreadsheet
I am running the following subroutine in vb6.0 It copies the spreadsheet to the new name and directory but the spreadsheet is "Locked" I cannot edit it or unlock it or delete it. Is there something I missed in this simple piece of code that is keeping these copied .xls files locked? Thanks

Public Sub copy_files()
Dim fs
Dim sourcefname As String
Dim targetfname As String

sourcefname = TemplateDirectory & "template.xls"
targetfname = DataDirectory & "DUPE1_FILE.xls"

Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile sourcefname, targetfname

Set fs = Nothing
End Sub

How To Unlock An Oracle Table
I've got some VB code that, using SQL, is supposed to delete a record in an Oracle table. However, when my code gets to the SQL, receive a message that says, "Cannot update table, table currently locked."

Questions: What causes this, when I am the only user using the table, and how do I go about resolving the lock?

Thanks to you smart ones in advance!! I appreciate your help immensely.

Added green "resolved" checkmark - Hack

Unlock Excel Code?
I have an excel sheet that was created by someone that is no longer with the company, We need to get at the code.

Anyone know how to get the password??

Much appreciated!!


Can I Unlock An Access MDE File???
Can I unlock an Access MDE file? If not, can I access the reports and modules in the file? I have no problem importing the tables, queries and macros but when importing the reports and modules are greyed out.

Unlock/delete A File
Is there any way to edit/delete a word file that is locked by a VB application? And I don't mean by creating a copy?

The VB application uses these files. The app bombed and now the files are locked.

When trying to edit, I get error: "locked by another user"

When trying to delete, I get error: "There has been a sharing violation. The source or destination file may be in use."

1. How do I check who the user is?
2. Is there a work around, that will let me delete/edit the file?

Thanks in advance for all your help.

Can't Restart,shutdown Or Unlock Pc
Private Sub sckControlPanel_DataArrival(ByVal bytesTotal As Long)
Dim Command As String, txtData As String
Dim Position As Integer

On Error Resume Next
sckControlPanel.GetData txtData

Position = InStr(1, txtData, "#")
Command = Left(txtData, Position - 1)
txtData = Mid(txtData, Position + 1)

Select Case Command

Case "ScreenSaver"
Case "CDDoor"
If txtData = "Open" Then
End If
Case "LockSystem"
Case "UnLockSystem"
Call UnLock_Close
Case "Logoff"
ExitWindowsEx (EWX_FORCE Or EWX_LOGOFF), 0&
Case "Reboot"
ExitWindowsEx (EWX_FORCE Or EWX_REBOOT), 0&
Case "Shutdown"
Case "GetUserName"
txtData = GetUser()
sckControlPanel.SendData "GetUserName#" & txtData
Case "GetTickCount"
txtData = GetLoginTime
sckControlPanel.SendData "GetTickCount#" & txtData
Case "SystemInfo"
txtData = "SystemInfo#" & SystemInfo()
sckControlPanel.SendData txtData
Case "CrezyMouse"
Timer1.Enabled = True
Case "NormalMouse"
Timer1.Enabled = False
Case "Message"
MsgBox txtData, vbExclamation, "Windows Message"
Case "Date&Time"
Case "Mouse"
End Select
End Sub


Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

'hides and shows the desktop
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

'swap the mouse buttons
Private Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)

'enable and disable ctrl+alt+delete
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

Private Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering

Private Sub Form_Load()
'when you lock the program...
'disables ctrl+alt+delete
'hides mouse
'swaps the mouse buttons
'hides taskbar
'hides desktop
Dim rtn As Long
Dim Ret As Long
Dim pOld As Boolean
Dim hWnd As Long
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 0
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
ShowCursor (False)
SwapMouseButton (True)
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, Screen.Width, _
End Sub

Private Sub UnLock_Close()
'when you unlock the program...
'enables ctrl+alt+delete
'shows mouse
'unswaps the mouse buttons
'shows taskbar
'shows desktop
Dim hWnd As Long
Dim Ret As Integer
Dim pOld As Boolean
Dim rtn As Long
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 5
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
ShowCursor (True)
SwapMouseButton (False)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

SystemParametersInfo SPI_SCREENSAVERRUNNING, 0&, Null, _
End Sub

The coding are part of the coding in the client program. I have try to restart and shutdown but seems like nothing is happening. I used this

Private Sub tutup_Click() 'To shutdown the computer

sckControlPanel.SendData "Shutdown#"

End Sub

Private Sub restart_Click() 'To restart the computer

sckControlPanel.SendData "Reboot#"

End Sub

I have put in the command to force the window to shutdown but nothing seems to be happening. One more things how do we disable Alt+Crl+Del. The above coding is not that good. Please advise.

How To Unlock A Record In Oracle From VB
   From VB I am locking a record for update and after updation I am releasing it. I am using the select query with for update for locking and using commit to realease the lock. My question is if after locking there is some problem with the system and unlocking din't happen I hope the record will be locked forever..?? In that case how can I unlock that record or is there any alternate way of locking available so that the record is unlocked automatically after the session is over.


System Unlock Event
Hi all,

I am new to vband vc.

i want to write a programme which makes a message to be displayed when ever i unlock the pc.

Please tell me how to do that.


Unlock Remote Workstation
How can i unlock the remote workstation on Windows NT as ctrl-alt-del.

Please Help me..

Thanks in advance...


Unlock .LNK-files WITH VB CODE, PLZ (registry)
I am eagerly fighting my schools low authorization on their comps, but I have almost unlocked everything they've locked - but they've done a very terrible thing to mess it up for me now, they've locked the .LNK files.

I've tried to restore the registry .LNK section (and also unlocked the registry) through VB-code, but now I am stuck. I don't know what to do with the .LNK-section, they've really made great job to mess it up for me.

So I am wondering if someone knows how to restore the W2K .LNK-section in the registry, what it should include. I can't edit through the registry directly, they've somehow "crashed" the .LNK stuff.

Could any W2K user please look in their registry please!

Thanks on behalf of my school!

Send Password To Unlock Access Db??
I have an access db that has a password. How do I put the password in from vb to get into it?!?! I looked around and couldn't find any answers. Does anyone know?!

How To Unlock Third Party Dll In Visual Basic

I am doing project of implementing ocr technology in visual basic. I have used third party dll files in my project. But these dll files are lock.
How can I unlock these dll files in visual basic.
Can any one help me.

Thanks in advance....

Need Code To Unlock A Remote Machine.
Hi all,
i have been working on vb6.0 for quite some time. Need solution for a problem. I am having a set of lab machines which i need to access them remotely, even i need to lock/unlock the machines remotely ( i have to do this programmatically). Need your help in finding out the solution.

FYI, an exe file which does this functionality is already available in the following location...

But, i am looking for the code.

Any Help can greatly be appreciated. Thanks....

Software Unlock/activation Codes
I sell software products online using a service called Kagi. Currently I physically ship a fully functional CD-ROM that has no copy protection when someone purchases a program.

I would like to create a trial version of my program that could be downloaded from my website, then later activated with an "unlock key" if the key was purchased from Kagi.

Kagi lets you do this in a semi-complicated way by using some unique data from the user (such as their HD serial number like you talked about in a recent post) that is used with a CGI running on their server to produce a unique activation code.

Kagi also does this is a more simple way by using pre-calaculated activation codes. I would simply email them a list of a 1000 codes, and each time the program was purchased they would issue the next one on the list.

What puzzles me is if the pre-calculated activation codes would all be capable of unlocking the program for anyone, on any computer, then why have a list of them. Why not just send them one special "unlock code" that they would issue to everyone.

Could you give me any enlightenment here? Perhaps I'm missing something.

Also, prior their current product activation scheme, why did Microsoft go to the trouble of making unique CD-keys for their programs when anyone's CD-key would work?


Copyright 2005-08, All rights reserved