2014년 8월 14일 목요일

VBA 에서 Web Data 수신

혹시 사용하게 될 지 몰라서 VBA에서 Web Data 추출하는 루틴을 기록해둠

Public Sub Sendxml()
    Dim hreq As New MSXML2.XMLHTTP60
    Dim url As String, postData As String
    
    url = "http://10.210.27.41/Candy/WorkProc"
    postData = ""
    
    hreq.Open "POST", url, False
    hreq.setRequestHeader "Content-Type", 
                          "application/x-www-form-urlencoded"
    hreq.send (postData)
    
    If hreq.Status = 200 Then
        hreq.getAllResponseHeaders
        MsgBox hreq.responseText
        
    Else
        MsgBox "Read Failed!!"
    End If
End Sub

참조할만한 게시물
 http://blogs.msdn.com/b/marcelolr/archive/2010/02/16/consuming-odata-with-office-vba-part-i.aspx