Boa noite
O código abaixo cria um ficheiro de texto "Locked.txt". Como criar o mesmo mas "Oculto" ?
O código abaixo cria um ficheiro de texto "Locked.txt". Como criar o mesmo mas "Oculto" ?
- Código:
Private Sub cmdLock_Click()
On Error GoTo Err_Handler
Dim fso As Object, aFile As Object
Dim blnLock As Boolean
Dim strText1 As String, strText2 As String
'Set fso = CreateObject("Scripting.FileSystemObject")
blnLock = False
If Me.cmdLock.Caption = "&Lock Database" Then
Me.lblLocked.Visible = False
If Nz(Me.txtFile, "") = "" Then
strPath = CurrentProject.Path
If FormattedMsgBox("Are you SURE you want to LOCK the current database? " & _
"@ @", vbExclamation + vbYesNo + vbDefaultButton2, "Lock current database?") = vbNo Then Exit Sub
Else
strPath = Me.txtPath
End If
' Debug.Print strPath
strText1 = "This will create a textfile 'Locked.txt' in the selected database folder. "
strText2 = "If this file is present in a database folder, users will see a message when the database is opened. " & vbNewLine & _
"The message states that the database is not available due to system maintenance then the database exits. " & vbNewLine & vbNewLine & _
"NOTE: For this to work successfully: " & vbNewLine & _
"1. COPY the module 'modLockedOut' from the 'CheckCurrentUsers' database to the destination database " & vbNewLine & _
"2. ADD the line 'Call LockedOut' to the Form_Load event of the destination database "
If FormattedMsgBox(strText1 & "@" & strText2 & vbNewLine & vbNewLine & "Do you want to do this now? @", _
vbExclamation + vbYesNo + vbDefaultButton2, "Lock selected database?") = vbYes Then
blnLock = True
strMsg = strText2
Open strPath & "\Locked.txt" For Output As #1
Print #1, strMsg
Close #1
Me.cmdLock.Caption = "&Unlock Database"
Me.lblLocked.Visible = True
End If
Else
strPath = Nz(Me.txtPath, CurrentProject.Path)
strFileName = strPath & "\Locked.txt"
'delete locked.txt file
If Dir(strFileName) <> "" Then
'First remove read only attribute, if set
SetAttr strFileName, vbNormal
Kill strFileName
End If
Me.cmdLock.Caption = "&Lock Database"
Me.lblLocked.Visible = False
End If