Solved

web control question

Posted on 2002-03-18
15
268 Views
Last Modified: 2012-05-04
I tried to use the hes's answer to my previous question as following:

Using the webbrouser control if you know the field name you can do something like this. This logs you
into yahoo mail
(Web1 is the WebBrouser1 control name in this example)
dim comp2 as boolean
Web1.Navigate2 "http://login.yahoo.com/config/mail?.intl=us&.lg=us"
Comp2 = False
Do Until Comp2 = True
 DoEvents
Loop
Web1.Document.All("loginMemberName").Value = "Your UserId"
Web1.Document.All("loginPassword").Value = "Your Password"
Web1.Document.Forms(0).submit
Comp2 = False
Do Until Comp2 = True
 DoEvents
Loop

Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
 Comp2 = True
End Sub

I got the error message as

Runtime error '91', object variable or with block variable not set.

Any idea how to fix it?

0
Comment
Question by:llucy88
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 20

Expert Comment

by:hes
Comment Utility
which variable do you get the error on, whoops never mind. Change dim comp2 as boolean to
Private Comp2 as Boolean and put in the Declaration part of the form. or Public Comp2 as Boolean in a module
0
 

Author Comment

by:llucy88
Comment Utility
I think it is more involved with the "send field value to the "HTML document".
Web1.Document.All("loginMemberName").Value = "Your UserId"
Web1.Document.All("loginPassword").Value = "Your Password"

It seems that I need define the "document" object before I can call the method to send the "field values".
I found some info. on the msdn page regarding web control, not clearly enough for me to figure it out. Any good links?

Thanks!
Lucy
0
 
LVL 20

Expert Comment

by:hes
Comment Utility
Replace the loginMemberName to login
loginMemberName is for EE the box on yahoo is named login

replace loginPassword with passwd

then try it
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Besides,
Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
if (pDisp is wb1.object) then Comp2 = True
End Sub
0
 
LVL 20

Expert Comment

by:hes
Comment Utility
Lucy,
Are you still having problems
0
 

Author Comment

by:llucy88
Comment Utility
I am still having the same error. I put the code as below. (I have a button as "command1" on the "form",

*********************************
Option Explicit

Dim comp2 As Boolean

Private Sub Command1_Click()
Dim oobject

Web1.Navigate2 "http://login.yahoo.com/config/mail?.intl=us&.lg=us"
comp2 = False
Do Until comp2 = True
 DoEvents
Loop
Set oobject = Web1.Document

oobject.All.Item("Yahoo! ID:").Value = "testlogin"
oobject.All.Item("Password:").Value = "testpassword"
oobject.Forms(0).submit
comp2 = False
Do Until comp2 = True
 DoEvents
Loop
End Sub

Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is Web1.object) Then comp2 = True
End Sub


************************************************

Thanks!

Lucy
0
 
LVL 20

Expert Comment

by:hes
Comment Utility
In the origional replace

Web1.Document.All("login").Value = "Your UserId"
Web1.Document.All("loginPassword").Value = "Your Password"
Web1.Document.Forms(0).submit

with

Web1.Document.All("loginMemberName").Value = "Your UserId"
Web1.Document.All("passwd").Value = "Your Password"
Web1.Document.Forms(0).submit
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 20

Expert Comment

by:hes
Comment Utility
That should be

In the origional replace

Web1.Document.All("loginMemberName").Value = "Your UserId"
Web1.Document.All("loginPassword").Value = "Your Password"
Web1.Document.Forms(0).submit

with

Web1.Document.All("login").Value = "Your UserId"
Web1.Document.All("passwd").Value = "Your Password"
Web1.Document.Forms(0).submit
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
or
Web1.Document.All("login").Value = "Your UserId"
Web1.Document.All("passwd").Value = "Your Password"
Web1.Document.all(".save").click
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
or a more simple:
'form_load:

Web1.Navigate2 "http://login.yahoo.com/config/mail?.intl=us&.lg=us"
Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
if (pDisp is web1.object) then
   if instr("login.yahoo.com/config/mail?.intl=us&.lg=us") then
      Web1.Document.All("login").Value = "Your UserId"
      Web1.Document.All("passwd").Value = "Your Password"
      Web1.Document.all(".save").click      
   end if
end if
End Sub





0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
oops! sorry:

'form_load:

Web1.Navigate2 "http://login.yahoo.com/config/mail?.intl=us&.lg=us"
Private Sub Web1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
if (pDisp is web1.object) then
   if instr(1,url,"login.yahoo.com/config/mail?.intl=us&.lg=us",vbtextcompare) then
      Web1.Document.All("login").Value = "Your UserId"
      Web1.Document.All("passwd").Value = "Your Password"
      Web1.Document.all(".save").click      
   end if
end if
End Sub





0
 

Author Comment

by:llucy88
Comment Utility
Thanks a lot, It works. But it seems that the value submit to the form is not based on the "field name" display on the webpage??? As on the "yahoo" site, the login field name is "Yahoo! ID:", the password field name is "Password:". I am little confused.
If I want to submit values based on the fieldname (not only login name, password, it could be any information based on the fieldson the web page), this method is not useful?????

Thanks a lot!

Lucy
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
Comment Utility
Strange. Field names don't has to be a problem since they are not used. I used that code to login to hotmail for about a  year without any  problem.
Take a look what i am saying at:
www.angelfire.com/realm/vb-shared/index.html under "IE DOM..." topic.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20218546.html
http://www.experts-exchange.com/questions/Q.20269728.html
http://www.experts-exchange.com/questions/Q.20278365.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Thanks for "A" grade!
If you need more help, here i am.
Cheers
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now