Thursday, October 22, 2009

How to Post and Get from HTTP using VB6

Thanks to some help from Doc's Coding, I was able to get Microsoft Excel 2000 to do a GET request.

I had to add a reference by going to Tools|Reference, then select Microsoft winhttp service version 5.1

Then I added the following code:


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 22/10/2009 by John Hufnagel
'
url = "http://www.google.ca/"
postmydata = "variable=data&variable2=data2"
Dim HttpReq As Object

Set HttpReq = New WinHttpRequest

HttpReq.Open "POST", url, False
'or use GET instead of POST

HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

HttpReq.send postmydata
'Note - if using GET set postmydata to ""

MsgBox (HttpReq.responseText)

End Sub

Now that I have the basic GET working, the next challange is to make a Yahoo! Web Service REST Call

No comments:

Post a Comment

Solidworks macros eith ChatGPT

 Record a simple using thr Solidworks macro recorder, upload it to ChatGPT, and explain to ChatGPT how you want it changed:  https://youtu.b...