How to select a value from drop down box in internet explorer jsf page

44 Views Asked by At

I have a webpage to fill with excel data. I am a beginner in VBA. I manage to fill the boxes, however i dont know how to select a date value, tick a box and select a value from a drop down list.

here is my code (which is interrupted for manual actions as i dont know how to proceed with those) Code which is not working i put in comment mode

    Sub fillwebform()

 
' here I define Internet Explorer
Dim IE As Object
Dim Doc As HTMLDocument
Dim doccomplete As Boolean
Dim nodeInput As Object



Call Shell("cmd.exe taskkill /F /IM /c iexplore.exe")
Set IE = New InternetExplorerMedium
IE.Visible = True
IE.Navigate "https://eservices.minfin.fgov.be/webForm/public/pdie/pdie.jsf"


'Doc.getElementById("j_idt49_input").ReadOnly = False
'Doc.getElementById("j_idt49_input").Value = "11/2021"
'Set evt = IE.Document.createEvent("keyboardevent")
'evt.initEvent "change", True, False
'Doc.getElementById("j_idt49_input").dispatchEvent evt


MsgBox ("Selecteer volgende periode: " & sht.Range("j3").Value) '--> here i need to select a value in the date selection because above code is not working
Application.Wait (Now + TimeValue("0:00:1"))
  
Doc.getElementById("nomEntreprise").Click
Doc.getElementById("nomEntreprise").Value = "dummy1"
Doc.getElementById("numTva").Value = "dummy2"
Doc.getElementById("numAutorisation").Value = "dummy3"

Doc.getElementById("idWizard_next").Click

Do Until IE.readyState = 4
        DoEvents
Loop
On Error Resume Next

'Doc.getElementById("categorieCadreA:2").Click
'Doc.getElementById("categorieCadreA:2").Value = True
'Doc.findelementbyclass("ui-chkbox ui-widget").Click

'Dim elements As Variant
'elements = Doc.getElementsByClassName("ui-chkbox ui-widget")
'For Each element In elements
'element.Click
'Next

MsgBox ("klik voertuigen groter dan 7.5T") '--> here i need to tick that box
Application.Wait (Now + TimeValue("0:00:1"))

For i = 6 To LastRow - 1

'nummerplaat
Application.Wait DateAdd("s", 1, Now)
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":registrationId").Focus
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":registrationId").Value = sht.Range("l" & i).Value
Set evt = IE.Document.createEvent("keyboardevent")
evt.initEvent "change", True, False
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":registrationId").dispatchEvent evt

'eigendomsbewijs

MsgBox ("klik op selectie eigendom en selectgeer: " & sht.Range("m" & i).Value & ". Klik dan hier op ok") '--> here i need to select a dropdown value, below code not working
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription").Focus
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_focus").Focus
'Set Choices = Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_input")
'For Each elem In Choices.getElementsByTagName("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_input")
'If elem.Value = "A" Then elem.Selected = True: Exit For
'Next elem
'
'
'
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription").Focus
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription").Click
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_focus").Focus
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_focus").Click
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_focus").ariaActivedescendant = "cliquetsAData:0:cadreAData:" & i - 1 & ":preuve_inscription_1"
'Set evt = IE.Document.createEvent("keyboardevent")
'evt.initEvent "change", True, False
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":invoicesId_input").dispatchEvent evt
'Application.Wait DateAdd("s", 1, Now)

'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription").Focus
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription").Click
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_1").Focus
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":preuve_inscription_1").Click
'Set evt = IE.Document.createEvent("keyboardevent")
'evt.initEvent "change", True, False
'Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & '":preuve_inscription_1").dispatchEvent evt


'aantal facturen
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":invoicesId_input").Focus
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":invoicesId_input").Value = sht.Range("p" & i).Value
Set evt = IE.Document.createEvent("keyboardevent")
evt.initEvent "change", True, False
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":invoicesId_input").dispatchEvent evt

'liters
Dim number As String
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":tankedId_input").Focus
number = CStr(sht.Range("q" & i).Value)
number = Replace(number, ".", ",")
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":tankedId_input").Value = number
Set evt = IE.Document.createEvent("keyboardevent")
evt.initEvent "change", True, False
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":tankedId_input").dispatchEvent evt
Application.Wait DateAdd("s", 1, Now)


'kilometers
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":kmId_input").Focus
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":kmId_input").Value = sht.Range("r" & i).Value
Set evt = IE.Document.createEvent("keyboardevent")
evt.initEvent "change", True, False
Doc.getElementById("cliquetsAData:0:cadreAData:" & i - 6 & ":kmId_input").dispatchEvent evt
Application.Wait DateAdd("s", 1, Now)

sht.Range("s" & i).Value = "Created"

If i = LastRow - 1 Then
Else: Doc.getElementById("cliquetsAData:0:j_idt128").Click
End If

Next i

End Sub
0

There are 0 best solutions below