Solved

Using WinHTTP Services

Posted on 2013-02-02
9
479 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…

911 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

23 Experts available now in Live!

Get 1:1 Help Now