Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I'm in troubles while surfing a web site: the deadlock is the modal window you can see in the image.
https://imgur.com/a/iq4KSDY
It absolutely blocks every Excel actions: I've to manually click "OK" in order to unblock the process.
I've tried the following solution, but unsuccessfully.
(the red line is the instruction triggering the window.
Probably the approach is wrong: may be I need to work with two Excel instances or something like that?
Thank's in advance for your suggestion.
I'm in troubles while surfing a web site: the deadlock is the modal window you can see in the image.
https://imgur.com/a/iq4KSDY
It absolutely blocks every Excel actions: I've to manually click "OK" in order to unblock the process.
I've tried the following solution, but unsuccessfully.
(the red line is the instruction triggering the window.
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public 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
Public Const BM_CLICK = &HF5&
Sub navigatewebsite()
'do stuff: login to the site and navigating
Dim i As Long, hWND As Long, childHWND As Long
'class = rgRow
Dim elements As Object
Set elements = HTMLdoc.getElementsByClassName("rgRow")
Dim ele As Object
For Each ele In elements
If ele.innerText = "3625" Or "3626" Or "3628" Or "3630" Or _
"3631" Or "3649" Or "3651" Or "3658" Or "6376" Or _
"3627" Or "3650" Or "3659" Or "3652" Then
[COLOR="#FF0000"][B]ele.Click[/B][/COLOR]
While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
DoEvents
If IE.Busy Then
DoEvents
hWND = FindWindow(vbNullString, "Messaggio della pagina Web")
If hWND <> 0 Then childHWND = FindWindowEx(hWND, ByVal 0&, "Button", "OK")
If childHWND <> 0 Then SendMessage childHWND, BM_CLICK, 0, 0
End If
Wend
Exit For
End If 'end If ele.innerText
Next ele
'do stuff
end sub
Probably the approach is wrong: may be I need to work with two Excel instances or something like that?
Thank's in advance for your suggestion.
Last edited: