Hello all,
I`m trying to click a link in Internet Explorer using VBA. Tried a lot of things I could think of, but nothing seems to work.
I tried everything I could think of or find in the internet, but nothing worked so far. I know that normal .Click is not working in this website, so I use .Focus and then .SendKeys in all other places and it usually works. But with this part for some reason it is stuck.. In this case the macro should click on the C letter and open all C letter list, but it is not clicking, but it finds and focuses on the right letter. Any ideas how to fix this?
The whole code:
The part that is not clicking:
I`m trying to click a link in Internet Explorer using VBA. Tried a lot of things I could think of, but nothing seems to work.
I tried everything I could think of or find in the internet, but nothing worked so far. I know that normal .Click is not working in this website, so I use .Focus and then .SendKeys in all other places and it usually works. But with this part for some reason it is stuck.. In this case the macro should click on the C letter and open all C letter list, but it is not clicking, but it finds and focuses on the right letter. Any ideas how to fix this?
The whole code:
Code:
Sub FN_CurrencyLetter_TEST()
Set objShell = CreateObject("Shell.Application")
Set objAllWindows = objShell.Windows
For Each ow In objAllWindows
If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
If (InStr(1, ow.LocationURL, "westernunion", vbTextCompare)) Then
Set objGoogle = ow
End If
End If
Next
If objGoogle Is Nothing Then
Else
Set objPage = objGoogle.Document
Dim HWNDSrc As Long
HWNDSrc = objGoogle.HWND
SetForegroundWindow HWNDSrc
valiuta = "CZK"
Dim briedis As String
Z = 0
PazymejoRaide = False
Do Until (PazymejoRaide = True Or Z = 3)
For Each element In objPage.getElementsByClassName("btn btn1")
If element.innertext = "Add" Then element.Focus: Exit For
Next element
kartojam:
Dim YD As String
e = 0
f = 0
For Each taip In objPage.getElementsByClassName("geoPaginationPanel")
If taip.getAttribute("eventproxy") Like "isc_AlphabeticalClientPagination*" Then
YD = taip.ID
taip.Focus
Application.SendKeys " "
Exit For
End If
Next taip
For Each elnias In objPage.getElementByID(YD).getElementsByTagName("div")
If (elnias.getAttribute("eventproxy") Like "isc_SafeLabel*" And elnias.innertext = Left(valiuta, 1)) Then
briedis = elnias.ID
elnias.Focus
Sleep 100
Application.SendKeys " ", True
FnWait (1)
Exit For
End If
Next elnias
Do While objGoogle.Busy: DoEvents: Loop
Do While objGoogle.readyState <> 4: DoEvents: Loop
End If
End Sub
The part that is not clicking:
Code:
For Each elnias In objPage.getElementByID(YD).getElementsByTagName("div") If (elnias.getAttribute("eventproxy") Like "isc_SafeLabel*" And elnias.innertext = Left(valiuta, 1)) Then
briedis = elnias.ID
elnias.Focus
Sleep 100
Application.SendKeys " ", True
FnWait (1)
Exit For
End If
Next elnias