- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
|
Dim vbProj As Object
Dim sPassword As String
On Error GoTo ErrorHandler
sPassword = sVBEPW
'Check to see if VBA project is already unlocked
If objExcelApp.VBE.ActiveVBProject.Protection < 1 Then Exit Function
'SendKeys is the only way
If sPassword = ^^ Or sPassword = ++ Then
sPassword =
Exit Function
ElseIf Right(sPassword, 2) = ^^ Or Right(sPassword, 2) = ++ Then
sPassword =
Exit Function
Else
With objExcelApp
.SendKeys(%{F11}, True)
.SendKeys(^r, True)
.SendKeys({DOWN}, True)
.SendKeys(sPassword, True)
.SendKeys(~, True)
End With
'objExcelApp..SendKeys(sPassword & ~~ & {ESC})
'objExcelApp.VBE.CommandBars(1).FindControl(Id:=2578, Recursive:=True).Execute()
End If
'Not the right password
'If objExcelApp.VBE.ActiveVBProject.Protection = 1 Then
'objExcelApp.Application.SendKeys(%{F11}, True)
'UnprotectVBProject = False
'Exit Function
'End If
UnprotectVBProject = True
End Sub
'May i know why this not working .... million thanks |
|