Re : enregistrer une feuille excel au format JPG
Bonjour luckiluc,
Comprends pas, qu'est-ce que ce module ?
A+
le module est prévu pour me crée un mot de passe avec des *****
en voici le code
---------------------------------------------------------------
Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long
Private lgHook As Long
Private Declare Function GetClassName Lib "user32" _
Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" _
(ByVal hHook As Long) As Long
Sub Mot_de_passe_Simple()
Const WH_CBT As Long = &H5
Const GWL_HINSTANCE As Long = -6
Dim lgInst As Long, PassW As String, Authentification As String
If Sheets("maintenance").Visible = True Then Exit Sub
PassW = "votremotdepasse"
lgInst = GetWindowLong(GetActiveWindow(), GWL_HINSTANCE)
#If VBA6 Then
lgHook = SetWindowsHookEx(WH_CBT, AddressOf PassWord_InputBox_Simple, lgInst, GetCurrentThreadId)
#Else
lgHook = SetWindowsHookEx(WH_CBT, AddrOf("PassWord_InputBox_Simple"), lgInst, GetCurrentThreadId)
#End If
Authentification = InputBox("Veuillez entrer le mot de passe, svp.", "Attention Accès réservé !")
If Authentification = "" Or Authentification <> PassW Then
MsgBox "Le mot de passe que vous avez saisie est erroné ? "
Exit Sub
Else
Sheets("maintenance").Visible = xlSheetVisible
Sheets("maintenance").Activate
Sheets("index").Visible = False
End If
'MsgBox "Le mot de passe que vous avez saisie est : " & InputBox("Veuillez entrer le mot de passe, svp.", "Attention Accès réservé !")
End Sub
Private Function PassWord_InputBox_Simple(ByVal lMsg As Long, ByVal wParam As Long, ByRef lParam As Long) As Long
Const HCBT_CREATEWND = 3
Const GWL_STYLE = (-16)
Const ES_PASSWORD = &H20
Dim ClassName As String, RetVal As Long
If lMsg = HCBT_CREATEWND Then
ClassName = String$(128, Chr$(0))
RetVal = GetClassName(wParam, ClassName, Len(ClassName))
If Left(ClassName, RetVal) = "Edit" Then
SetWindowLong wParam, GWL_STYLE, GetWindowLong(wParam, GWL_STYLE) Or ES_PASSWORD
UnhookWindowsHookEx lgHook
End If
PassWord_InputBox_Simple = False
End If
End Function