Unlocking Password Protected VBA project

前端 未结 1 379
有刺的猬
有刺的猬 2021-01-27 11:09

I am trying to unlock a password protected excel sheet using code found here

I am successfully able to unlock the excel file, but I do not want the user to see any wind

相关标签:
1条回答
  • 2021-01-27 11:52

    @Amelie:

        Ret1 = FindWindow(vbNullString, "VBAProject - Project Properties")
    
    If Ret1 <> 0 Then
    ChildRet1 = FindWindowEx(Ret1, ByVal 0&, "Button", vbNullString)
    
    If ChildRet1 <> 0 Then
        strBuff = String(GetWindowTextLength(ChildRet1) + 1, Chr$(0))
    
        GetWindowText ChildRet1, strBuff, Len(strBuff)
    
        ButCap = strBuff
    
        Do While ChildRet1 <> 0
            If InStr(1, ButCap, "OK") Then
                OpenRet1 = ChildRet1
                Exit Do
            End If
    
            ChildRet1 = FindWindowEx(Ret, ChildRet1, "Button", vbNullString)
            strBuff = String(GetWindowTextLength(ChildRet1) + 1, Chr$(0))
            GetWindowText ChildRet1, strBuff, Len(strBuff)
            ButCap = strBuff
        Loop
    
        If OpenRet1 <> 0 Then SendMessageA OpenRet1, BM_CLICK, 0, vbNullString
    End If
    End If
    
    0 讨论(0)
提交回复
热议问题