2011-08-31 103 views
0

我想尽可能简单地执行来自MS访问的HTTP-GET隐藏的HTTP-GET请求,但没有任何额外的库/组件。从vba执行隐藏的http请求

只是一个简单的声明都需要。

有WinHttp离开大楼吗?

+1

没有你看看这个线程:http://stackoverflow.com/questions/158633/how-can-i-send-an-http-post-request-到一个服务器 - 从-Excel的使用,VBA? – JMax

回答

1

希望这有助于

Dim xhr As Object 
Dim webServiceURL As String 
Dim actionType As String 
Dim thisRequest As String 
Dim targetWord As String 

WebServiceURL = "http://services.aonaware.com/DictService/DictService.asmx/" 
actionType = "Define?word=" 
targetWord = "Marketplace" 
thisRequest = webServiceURL & actionType & targetWord 

'use late binding 
Set xhr = CreateObject("Microsoft.XMLHTTP") 

xhr.Open "GET", thisRequest, False 
xhr.Send 

If xhr.status = 200 Then 
    Debug.Print xhr.responseText 
    MsgBox xhr.getAllResponseHeaders 
Else 
    MsgBox xhr.status & ": " & xhr.statusText 
End If 

Set xhr = Nothing