0

VBA Codes

Dim ie As Object
Dim frm As Variant
Dim element, submitInput As Variant
Dim rowCollection, htmlRow As Variant
Dim rowSubContent, rowSubData As Variant
Dim i, j, k, pauseTime As Integer
Dim anchorRange As Range, cellRng As Range
Dim start

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "URL"
While ie.readyState <> 4: DoEvents: Wend
ie.Visible = True

ie.document.getElementByID("username").Value = "ABCD"
ie.document.getElementByID("password").Value = "1234"
ie.document.getElementByID("btnLogin").Click

Application.Wait (Now + TimeValue("00:00:20"))

'++++++ Authentication ++++++++++
ie.document.querySelector("[for='What is the brand name of your first watch?'] + input").Value = "Rado"
ie.document.querySelector("[for='Which is the cinema hall closest to your residence? '] + input").Value = "Inox"
ie.document.querySelector("[value='Submit']").Click

When macro fills Authentication answer automatically and Click submit button using above vba codes,

We can see mentioned value in fields but submit button revert massage that "Fill the Fields". When i filled same value using keyboard, its works fine, It takes only keyboard filled value

So suggest to solve Query

QHarr
  • 83,427
  • 12
  • 54
  • 101
Ashish
  • 83
  • 5
  • Please note that if you declare `Dim i, j, k, pauseTime As Integer` you only declare `pauseTime As Integer` but all the others `As Variant`. In VBA you must specify a type for **every** variable, otherwise VBA assumes `Variant`. Also I recommend [always to use Long instead of Integer](https://stackoverflow.com/a/26409520/3219613) in VBA since there is no benefit in `Integer` at all: `Dim i As Long, j As Long, k As Long, pauseTime As Long` – Pᴇʜ Dec 14 '18 at 16:05
  • I've seen this in a couple of places. As far as I can understand, when using an automated process to interact with DOM model, it doesn't always work. At this stage, I generally write a `WriteToField` UDF which basically: clicks on the field (a physical mouse LEFT click), uses `SendKeys` to write to the field and finally, presses `TAB` to exit out of the field (triggering any underlying processes). This tends to cure the problem – Zac Dec 14 '18 at 16:44
  • @Zac That would be interesting to see. – QHarr Dec 14 '18 at 16:54
  • Can you share the URL? – QHarr Dec 14 '18 at 16:54
  • @Zac Can you share an Example? – Ashish Dec 17 '18 at 10:16

0 Answers0