?
Solved

Using WinHTTP Services

Posted on 2013-02-02
9
Medium Priority
?
504 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
[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
  • 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
Industry Leaders: 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!

 

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

Technology Partners: 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!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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