I am using a web browser control to autologin to a webpage. When I intially gives the username and password,it works well.
And for the second time it is not taking the username and password from the code.I dont know where it take from I get the err messeag as attached here.
And the code is
From memory, the READYSTATE_COMPLETE occurs prior to DocumentComplete. That said
your wb1.Document wouldn't exist at this stage, of course until COMPLETE. Therefore,
(ditching the Do?Loop) and placing the .Document code in the relavent event should
ensure the Documnet object is in fact loaded.
if it still does it.. there may be another issue...
do this:
run it.. let it login.. when it gets to the login again and fails.. view source of the webbpage.. save it to a text and post it. lets take a look at it.
it seems whats happening is the objects are changing somehow.. OR there are multiple objects with the same name..
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Dear Static!,
First time the web page loads automatically with the username and password. And after some time that is in the document complete event is giving this error message. It is firing again and again.
If i end the program and re run the program it is loading automatically and goes to the welcome screen. The the document complete event fires. Then i get the error msg as posted here.
I tried this with other one site, but that site username and pwd is confi one.So i am trying this with our site. So that i can give the username and pwd.
ok.. heres the issue..
once Logged in.. (at least with our site).. the login username/password is gone. thats why u are getting the error.. you need to put a check in to see if the objects are there
you need a ref to the MS HTML Object Library
like this...
VB Code:
Public Function LoggedIn(HTML As HTMLDocument) As Boolean
On Error GoTo checkerr
Dim txt As HTMLInputTextElement
Set txt = HTML.All.vb_login_username
LoggedIn = False
Exit Function
checkerr:
LoggedIn = True
End Function
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
If Not LoggedIn(WebBrowser1.Document) Then
WebBrowser1.Document.All.username.Value = "xxxxx"
'etc...
End If
End If
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
And also it logs in automatically without checking the username and pwd.I couldnot able to get where it is getting the entries old entries wheather history or not?
where.. here? (in VBF)?
thats cause in VBF its a tricky button.. not typical button
heres is the code I use for my VBF webbrowser... this sets the username/password then clicks submit
VB Code:
Dim HTMLS As HTMLInputButtonElement
HTML.All.vb_login_username.Value = USER
HTML.All.vb_login_password.Value = PSWD
'Loop thru all input elements, find the type = submit with value of Log in
For Each HTMLS In HTML.getElementsByTagName("input")
If HTMLS.Type = "submit" And HTMLS.Value = "Log in" Then
HTMLS.Click
Exit For
End If
Next
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Dear Static,
I have missed the line
Set HTML = Webbrowser1.Document.
So only It was giving the error msg. Thanks for the reply.
Really you are wonderfull!!!!
Great Help?
Dear Static,
In the form i have filed called file.This is used for uploading files.In the browser window there is button called with value "Browse". If I click the browse button then a open dialog box is displayed. In that I have to select a file and click ok. I want to automate this one, How can I?
I want to upload a particular file to one a webpage. I have given the screen shot of that page.If I click the browse button a dialog box pop up and I have to select the file and click ok. As soon as I click the ok button it will display the file path in the text area. Here the that are is given as
Code:
<INPUT name="f_data" size="50" type="file">
I am not able to assign the value to this. If I am able to load the values then I can click the upload button as mentioned by you in this post.