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
Solved

Using WinHTTP Services

Posted on 2013-02-02
9
487 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

856 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