Connect to web service in MS Access with VBA

前端 未结 3 2004
遇见更好的自我
遇见更好的自我 2021-01-02 04:52

Is it possible to connect to a web service (for example send a HTTP Request) via VBA in Microsoft Access? For example, the user clicks a button on a form, t

3条回答
  •  无人及你
    2021-01-02 05:22

    This is the code , which I used. You need to first reference Microsoft XML V6 for this code to work.

    Public Sub GetPerson()
        'For API
        Dim reader As New XMLHTTP60
    
        reader.Open "GET", "www.exmple.com/users/5428a72c86abcdee98b7e359", False
        reader.setRequestHeader "Accept", "application/json"
        reader.send
    
    
        Do Until reader.ReadyState = 4
            DoEvents
        Loop
    
        If reader.Status = 200 Then
            Msgbox (reader.responseText)
        Else
            MsgBox "Unable to import data."
        End If
    End Sub
    

提交回复
热议问题