Consulting

Results 1 to 2 of 2

Thread: Filling web form with validation.

  1. #1
    VBAX Newbie
    Joined
    Mar 2018
    Posts
    1
    Location

    Question Filling web form with validation.

    I'm trying to fill a form (you can see it here) via VBA controlling IE.
    The problem is that after I manage to fill the textboxes with the values and click on "Neste", the values inserted get forgotten.
    You can use IE consol with these commands to see the problem:
    document.getElementById("Leilighet").click()
    document.getElementsByName("opprinneligByggeAar")[0].value = "1985"
    document.getElementsByName("boligensAreal")[0].value = "75"
    document.getElementsByClassName("button")[0].click()
    This is the VBA code I use so far:
    Sub DoIt()
        Dim IE As Object, element1, Rmax As Long, T as Integer, T2 as Integer
        Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = 1
                T2 = Timer
    Rfrsh:
                IE.navigate "https://www.skatteetaten.no/person/skatt/hjelp-til-riktig-skatt/bolig-og-eiendeler/bolig-eiendom-tomt/formuesverdi/boligverdikalkulator/"
                T = Timer
                Do While IE.readystate <> 4 Or IE.busy
    XEL:         If Timer - T > 15 Then GoTo Rfrsh
                    If Timer - T2 > 50 Then GoTo NoNet
                    DoEvents
                Loop
                IE.document.getElementByID(Cells(3, 2)).Click  '.Checked = True
                IE.document.getElementsByName("opprinneligByggeAar").Item(0).Value = "1985"
                IE.document.getElementsByName("boligensAreal").Item(0).Value = "75"
                Set element1 = IE.document.getElementsByClassName("button")
                For Each element1 In element1
                    If element1.innertext = "Neste" Then
                        element1.Click
                    End If
                Next
         Msgbox "Done!"
    NoNet:
    ex:
        IE.Quit
        Set IE = Nothing
        Set element1 = Nothing
    End Sub
    Additional info:
    The same problem existed when I used ".Checked = True" (shown in bold in the code) to check the radio button. And I could avoid that by clicking it instead.

    Can the reason be related to the validation? And that the validation occurs only after a click or something? I tried clicking on the textboxes after filling them and I got the same result.

    Thank you in advance & many thanks to everyone who helps others. This site helped me many many times.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Moderator Bump
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •