Solved

web control question

Posted on 2002-03-18
15
273 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6878001
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
ID: 6878085
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
ID: 6878111
Replace the loginMemberName to login
loginMemberName is for EE the box on yahoo is named login

replace loginPassword with passwd

then try it
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6878279
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
ID: 6890054
Lucy,
Are you still having problems
0
 

Author Comment

by:llucy88
ID: 6890096
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
ID: 6890191
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
 
LVL 20

Expert Comment

by:hes
ID: 6890193
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
ID: 6891099
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
ID: 6891105
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
ID: 6891107
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
ID: 6893076
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
ID: 6893413
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
ID: 6911900
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
ID: 6913740
Thanks for "A" grade!
If you need more help, here i am.
Cheers
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA filters 2 81
MS SQL Update query with connected table data 3 78
VBA: copy range dynamically based on config sheet v3 6 53
Modify Text File with Excel Macro 13 46
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

734 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