|
-
Jun 16th, 2008, 09:10 AM
#1
Thread Starter
Addicted Member
WebBrowser
I have a button that opens up a web page below
Code:
Private Sub cmdTimeClock_Click()
WebURL = "https://hrdirect.cox.com/psp/HRDIRECT/EMPLOYEE/HRMS/c/ROLE_EMPLOYEE.TL_SS_JOB_SRCH_CLK.GBL?NAVSTACK=Clear&PORTALPARAM_PTCNAV=HC_TL_SS_JOB_SRCH_CLK_GBL&EOPP.SCNode=HRMS&EOPP.SCPortal=EMPLOYEE&EOPP.SCName=HC_TIME_REPORTING&EOPP.SCLabel=My%20Time%20Reporting&EOP"
frmTimeClock.Show
End Sub
This code then brings up the web page and submits the information below....as you can se I have edited it to not automatically click the submit button because when it does the page redirects to a different page with the same address, causing a runtime error because it cant find the fields on the new page. I dont know how to drill down to the iner code to stop this. So I disabled that and now I'm trying to manually click the "submit" button on the page to log in. However I am still getting a runtime error. I think it is because it is trying to run the code again and not finding the 2 fields on the new page. How can I stop the code from running When I click on the submit button on my page? esentially stopping the runtime error.
Code:
Private Sub TimeClock_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If InStr(URL, WebURL) Then
TimeClock.Document.All("coxuserid").Value = "johndoe"
TimeClock.Document.All("pwd").Value = "xxxxxxxxxxxx"
'TimceClock.Document.All("submit").Click
' Redirects to a new page to select clock in or out
'TimeClock.Document.All("TL_RPTD_TIME_PUNCH_TYPE$0").selectedIndex = 1
Else
End If
End Sub
Last edited by percussiontech; Jun 16th, 2008 at 10:07 AM.
-
Jun 16th, 2008, 09:17 AM
#2
Re: WebBrowser
To stop any kind of run time error, simply add error trapping.
What error are you getting?
-
Jun 16th, 2008, 09:38 AM
#3
Thread Starter
Addicted Member
Re: WebBrowser
run time error 91
Object variable or With Block variable not set
-
Jun 16th, 2008, 09:41 AM
#4
Re: WebBrowser
You didn't include your actual userid and password in the code again, did you? If so, remove it poste-haste.
-
Jun 16th, 2008, 11:58 AM
#5
Re: WebBrowser
Again, like I told you before on your other threads you need to put in a variable counter. When you do the If InStr(URL, WebURL) Then statement and it enters the clause for the first time you know this is the correct page that has the fields on it that you want to fill in. So, fill in the fields and click the submit button The next time this sub is entered because the URL is the same but the page is different your code will not allow it to enter the same clause where you set the counter to 1 and your code will direct the flow to the second entry clause. Do something like this:
Code:
'
'
Private Sub WebBrowser1_DocumentComplete(..........., URL As Variant)
Static InCounter As Integer
InCounter = InCounter +1
If InStr(URL, WebURL) Then
Select Case InCounter
Case 1
'
' Do what is necessary for the page on the first entry into this Sub.
' This should be the page that has the fields on it that you need to
' fill in and submit it
'
Case 2
'
' Here is where it comes for the second entry into this Sub and this
' should be the page that you get because it was redirected to this
' page when you submitted the first page. This is the page that you
' need to find out how to drill down into the inner pages that are
' the results of the Frame Sets. I don't know how to do that.
'
Case Else
'
' If it comes here then you will have to check into it and see what is
' going on. Perhaps the server even sent a third page with the same
' URL or something is really screwed up and you will need to figure it
' out and then take appropiate actions.
'
End Select
Else
'
' Here this Sub was entered but it was not the URL that you started out
' with so you will need to see what is going on here.
'
End If
End Sub
-
Jun 16th, 2008, 12:01 PM
#6
Re: WebBrowser
 Originally Posted by percussiontech
run time error 91
Object variable or With Block variable not set
And what line of code is causing the error?
-
Jun 16th, 2008, 12:10 PM
#7
Re: WebBrowser
Hack, I have been working with him on this problem so I have good idea what the problem is and it is because he is not routing the next page to a new set of code and it always enters the same code as he had for the first page. The second page does not contain any of the fields that he is trying to fill in because they are located on Frame Set pages but only the root page is being presented (the page with the Frames on it) by the browser control when it enters the DocumentComplete event.
-
Jun 16th, 2008, 12:17 PM
#8
Thread Starter
Addicted Member
Re: WebBrowser
TimeClock.Document.All("coxuserid").Value = "john doe." Is the line of code that is having the error. but it only does that if i log into that page more than once every 4 hours if i use the program or if i bring the page up in IE. then use the program. if i use the program for the first time in the day it gives me a different error of somthing like "2ffeeee " something or other.
-
Jun 16th, 2008, 02:11 PM
#9
Thread Starter
Addicted Member
Re: WebBrowser
ok so here is the first runtime error i gte as described in the post above.
Run-time error '-2(fffffffe)'
the options are ok and help. if i click ok the program closes. If I click help nothing happens. So i am not sure what line of code is causing this.
PM me if you would like my project.
-
Jun 16th, 2008, 04:59 PM
#10
Re: WebBrowser
More than likely it appears to be an IE 6 error so it's nothing to do with your program or code. I Googled Web Error -2(fffffffe) and found no real help at all but did get the impression that it could be caused for several reasons.
As far as determining which like of code it is triggered on you will need to do a simple trial by elimination. Run your code and each time you run it start commenting each possible line that you think might be the cause. Also put in an On Error GoTo ErrHandler statement at the begin of the code then see if this error triggers your ErrHandler routine and if it does start checking for Err.Description and other things.
Code:
'
'
'
Private Sub Something(.........)
'
On Error GoTo ErrHandler
'
' Do your code here
'
Exit Sub
ErrHandler:
'
' If it enters here do some checking on Err.Description and
' other Err. properties
'
End Sub
-
Jun 16th, 2008, 05:59 PM
#11
Thread Starter
Addicted Member
Re: WebBrowser
Well I dont know........ I am lost. I did the code you told me to, to get the error and now it lets me go in without the error until i try to click on something else. Can I email you the project again?
Code:
Private Sub TimeClock_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'
On Error GoTo ErrHandler
'
If InStr(URL, WebURL) Then
TimeClock.Document.All("coxuserid").Value = "johndoe"
TimeClock.Document.All("pwd").Value = "xxxxxxxx"
WebBrowser2.Document.All("submit").Click
' Redirects to a new page to select clock in or out
'WebBrowser2.Document.All("TL_RPTD_TIME_PUNCH_TYPE$0").selectedIndex = 1
Else
End If
'
Exit Sub
ErrHandler:
End Sub
-
Jun 16th, 2008, 06:40 PM
#12
Re: WebBrowser
Can I email you the project again?
No problem.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|