اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

تنفيذ ماكرو بعد كتابة كلمة المرور


الردود الموصى بها

بسم الله الرحمن الرحيم

من فضل حضراتكم جميعا

برجاء مساعدى في حل تلك المشكلة

p_1795lanye1.jpg

Compil error:

Ambiguous name detected: InputBoxDK

عند تنفيذ هذا الكود

Private Sub ButtonGo_Click()
Dim strAdminPWord As String
strAdminPWord = InputBoxDK("Password required to proceed.", "من فضلك أدخل كلمة المرور للدخول")
If strAdminPWord = "1234" Then
    MsgBox "كلمة المرور صحيحة ", vbOKOnly, "success"

    Me.Hide

Application.Visible = True
ActiveWindow.DisplayHeadings = False
Application.DisplayFormulaBar = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",false)"
ActiveWindow.DisplayWorkbookTabs = False
    Sheets("البيانات الرئيسية").Select
    Worksheets("البيانات الرئيسية").ScrollArea = "A1:A1"
    Range("A1:A1").Select
Else
    MsgBox ("كلمة المرور خاطئة حاول مرة أخرى")
    
    Exit Sub
End If
Unload Me
End Sub

وشكرا لكم جميعا

رابط هذا التعليق
شارك

بارك الله فيكم جميعا تم حل المشكلة وذلك عندما وجدت تكرار للكود الخاص بكلمة السر كان موجود مرتين قمت بحذف واحد منهم .

والحمد لله كله تمام

مرفق الكود الخاص عمل كلمة السر على هيئة نجوم حتى لا يعرفها أحد .

Option Explicit
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
                                                      ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
 
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) 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 Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
 
Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" _
                                            (ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, _
                                            ByVal wParam As Long, ByVal lParam As Long) 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 GetCurrentThreadId Lib "kernel32" () As Long

Private Const EM_SETPASSWORDCHAR = &HCC
Private Const WH_CBT = 5
Private Const HCBT_ACTIVATE = 5
Private Const HC_ACTION = 0
 
Private hHook As Long
 
Public Function NewProc(ByVal lngCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim RetVal
    Dim strClassName As String, lngBuffer As Long
 
    If lngCode < HC_ACTION Then
        NewProc = CallNextHookEx(hHook, lngCode, wParam, lParam)
        Exit Function
    End If
 
    strClassName = String$(256, " ")
    lngBuffer = 255
 
    If lngCode = HCBT_ACTIVATE Then
 
        RetVal = GetClassName(wParam, strClassName, lngBuffer)
 
        If Left$(strClassName, RetVal) = "#32770" Then
 
            SendDlgItemMessage wParam, &H1324, EM_SETPASSWORDCHAR, Asc("*"), &H0
        End If
 
    End If
 
   
    CallNextHookEx hHook, lngCode, wParam, lParam
 
End Function
 
Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, _
                        Optional YPos, Optional HelpFile, Optional Context) As String
 
    Dim lngModHwnd As Long, lngThreadID As Long
 
    lngThreadID = GetCurrentThreadId
    lngModHwnd = GetModuleHandle(vbNullString)
 
    hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
 
    InputBoxDK = InputBox(Prompt, Title, Default, XPos, YPos, HelpFile, Context)
    UnhookWindowsHookEx hHook
 
End Function

 

  • Like 1
رابط هذا التعليق
شارك

  • 2 weeks later...

تفضلي إليك ملف لتجربة الكود على تنفيذ الأمر بعد وضع كلمة المرور على هيئة نجوم

كلمة المرور هي ( 123 )

ماكرو1.xlsm

  • Thanks 1
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information