我在下面运行以下代码,但是在h = ie.hwnd行上出现运行时错误91。但是,当我在另一个模块中定义此变量时,不会出现此错误。我该如何解决该错误?
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
'Public Const CB_FINDSTRING = &H14C
Public Const WM_CLOSE = &H10
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Sub ClickSave() '(ClaimNumber As String)
Sleep 1000
Dim o As IUIAutomation
Set o = New CUIAutomation
Dim ie As InternetExplorer
Dim Completed As Object
Do
Dim h As Long
h = ie.hwnd 'Error on this line :(
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
If h <> 0 Then
Dim count As Long
count = 0
Exit Do
Else
Sleep 100
count = count + 1
If count = 50 Then Exit Sub
End If
Loop
End Sub