Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50057

IE.document.getElementByID returns run-time error '91'

$
0
0
Hello,
I have a VBA module that opens IE and tries to enter a user name into the text box. I have references to the MS HTML object library and the MS internet controls library.


The code works fine with this page... https://patriotweb.gmu.edu/pls/prod/twbkwbis.P_WWWLogin (the input box is: user name here)

But for this page it returns an error ... http://www.ncsu.edu/grad/applygrad.htm (the input box here is pin)

I know that there must be some difference in the structure of the two pages that is causing this problem, but I haven't been able to come up with a workaround.

Here is the code I have been trying... Any explanation or recommendations would be greatly appreciated!!

Code:

  Sub test()

      Dim IE As New InternetExplorer
   
      IE.navigate ("https://patriotweb.gmu.edu/pls/prod/twbkwbis.P_WWWLogin")

      While IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
      IE.Visible = True

      IE.document.getElementById("UserID").Value = "sfdsfs"
     
      IE.navigate("http://www.ncsu.edu/applygrad")

      while IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
       
      IE.document.getElementById("userid").Value = "test"  '<< this line gives me an error: Run-time error '91' Object variable or With block variable not set.

end sub


Viewing all articles
Browse latest Browse all 50057

Trending Articles