Solved

Using WinHTTP Services

Posted on 2013-02-02
9
474 Views
Last Modified: 2013-02-03
I am able to send a POST command to a web page via program code using WinHttp Services.

How would I go about receiving the response in a web browser?

I have tried using POST with  the Internet Transfer Control but it doesn't pass parameters to the web page.
Inet1.Execute Inet1.URL, "POST",  "P1=Something&P2=SomethingElse"

WinHTTP does send data properly but need response in browser.


Private Sub Command1_Click()

    Dim http As WinHttpRequest
    Set http = New WinHttpRequest
    
    http.Open "POST", "http://www.txxx.com/mailinfo/inforequest.asp", False
    http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    http.Send "P1=Something&P2=SomethingElse"
    
    'HOW DO I GET RESPONSETEXT TO SHOW UP IN A BROWSER?
    Debug.Print http.ResponseText
    
End Sub

Open in new window

0
Comment
Question by:trims30
  • 5
  • 4
9 Comments
 

Author Comment

by:trims30
ID: 38847982
Found another way that has possibilities... it works on a test page that I setup but not on the specific site I'm working with.

I get Runtime error 91 - Object variable not set
when attempting to set model number.

What am I missing??


My VB Code......

   Private Sub Form_Load()
        WebBrowser1.Navigate "lookup3.toro.com/partdex/index.cfm?xCaller=Toro"
     End Sub
 
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

'Place Model Number in Field and force Search
    WebBrowser1.Document.All("vModelNum").Value = "04530"
    WebBrowser1.Document.All.TOGSearch.Click

     End Sub

Open in new window


Here's Form section of Webpage....
<form METHOD="POST" ACTION="dosearch.cfm?xCaller=Toro" NAME="frmOgSrch">
                        <table border="0" cellspacing="0" cellpadding="0" bgcolor="">
                           <tr>
                              <td bgcolor="#FFFFFF" valign="bottom" align="right" height="30">&nbsp;Enter Model Number/Product Name&nbsp;&nbsp;<input type="text" id="vModelNum" name="vModelNum" size="20" maxlength="30" style="width: 200px"></td>
                              <td bgcolor="#FFFFFF" valign="bottom" align="center" height="30">&nbsp;&nbsp;&nbsp;<a href="#" onClick="popmodl('frmOgSrch.vModelNum', 'Toro'); return false;">View Model List</a></td>
                           </tr>
                           <tr>
                              
                              <td colspan="2" bgcolor="#FFFFFF" valign="bottom" align="center" height="30"><input type="radio" name="vProdType" value="All" checked>Equipment&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="vProdType" value="Irrigation">Irrigation</td>
                           </tr>
                           <tr>
                              <td colspan="2" bgcolor="#FFFFFF" valign="bottom" align="center" height="30">&nbsp;&nbsp;&nbsp;<input type="submit" value="Search" name="TOGSearch" class="smallinput">&nbsp;&nbsp;&nbsp;</td>
                           </tr>
                        </table>
                     </form>

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 38848367
Hi, try
    WebBrowser1.Document.frmOGSrch.vModelNum.Value = "04530"
    WebBrowser1.Document.frmOGSrch.TOGSearch.Click

Rob.
0
 

Author Comment

by:trims30
ID: 38848598
Rob:
Thanks for the reply -

That gives error 438 -object doesn't support property or method when setting modelnumber value.


Lee
0
 

Author Comment

by:trims30
ID: 38849137
Both of these formats work on another site.

    
    WebBrowser1.Document.userlogin.UserID.Value = "Sammy"
    WebBrowser1.Document.userlogin.login.Click

or

    WebBrowser1.Document.All("UserID").Value = "Sammy"
    WebBrowser1.Document.All("login").Click

Open in new window


So why doesn't my submission of Model Number work against the form section of the Toro web page I included previously?

Can someone try it  - see if they can get it to work - and let me know how it's done??

Lee
0
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!

 
LVL 65

Expert Comment

by:RobSampson
ID: 38849294
Hi, I haven't tested it yet, but you can also try
WebBrowser1.document.getElementById("vModelNum").value = "04530"
WebBrowser1.document.getElementById("TOGSearch").Click

Rob.
0
 

Author Comment

by:trims30
ID: 38849323
Still get runtime error 91 on

WebBrowser1.Document.getElementById("vModelNum").Value = "04530"

Open in new window


looks to me like web page is somehow locking out references to elements.
Could that be?
Any Work Around if that's the case?

Lee
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 150 total points
ID: 38849611
Hi, I figured it out.  Change this
        WebBrowser1.Navigate "lookup3.toro.com/partdex/index.cfm?xCaller=Toro"
 
to this:
        WebBrowser1.Navigate "lookup3.toro.com/partdex/modlsrch.cfm?xCaller=Toro"

Then you can use
        WebBrowser1.Document.frmOgSrch.vModelNum.Value = "04530"
        WebBrowser1.Document.frmOgSrch.TOGSearch.Click

It looks like the site was changing addresses, and so wouldn't expose anything to control.

Regards,

Rob.
0
 

Author Closing Comment

by:trims30
ID: 38849653
Very Nice - Thanks a million.

Regards,


Lee
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 38849684
No problem. Thanks for the grade.

Rob.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

13 Experts available now in Live!

Get 1:1 Help Now