Solved

Using WinHTTP Services

Posted on 2013-02-02
9
492 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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 …
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 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…

705 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