Rachunek serwis internetowy w Excelu

Czy w module VBA w Excelu 2007 można wywołać usługę WWW? Jeśli tak, jakieś fragmenty kodu? Jak dodać odnośnik internetowy?

Author: bluish, 2009-01-24

4 answers

Yes You Can!

Pracowałem nad projektem, który to zrobił (patrz komentarz). Niestety nie ma próbek kodu z tego, ale googling ujawnił te:

Jak można zintegrować dane z kilku usług internetowych za pomocą Excel i VBA

Krok po kroku: Korzystanie z usług internetowych przez VBA (Excel lub Word)

VBA: Consumer SOAP Web Services

 23
Author: Mostlyharmless,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-19 14:35:33
 6
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-01-29 21:05:04

Aby uzyskać zaktualizowaną odpowiedź zobacz to pytanie:

Wywołanie usługi internetowej za pomocą kodu VBA w Excelu 2010

Oba wątki powinny być połączone.

 3
Author: dgorissen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:44:21

W programie Microsoft Excel Office 2007 spróbuj zainstalować wtyczkę "Web Service Reference Tool". I korzystać z WSDL i dodać Usługi internetowe. I użyj poniższego kodu w module, aby pobrać niezbędne dane z serwisu internetowego.

Sub Demo()
    Dim XDoc As MSXML2.DOMDocument
    Dim xEmpDetails As MSXML2.IXMLDOMNode
    Dim xParent As MSXML2.IXMLDOMNode
    Dim xChild As MSXML2.IXMLDOMNode
    Dim query As String
    Dim Col, Row As Integer
    Dim objWS As New clsws_GlobalWeather

    Set XDoc = New MSXML2.DOMDocument
    XDoc.async = False
    XDoc.validateOnParse = False
    query = objWS.wsm_GetCitiesByCountry("india")

    If Not XDoc.LoadXML(query) Then  'strXML is the string with XML'
        Err.Raise XDoc.parseError.ErrorCode, , XDoc.parseError.reason
    End If
    XDoc.LoadXML (query)

    Set xEmpDetails = XDoc.DocumentElement
    Set xParent = xEmpDetails.FirstChild
    Worksheets("Sheet3").Cells(1, 1).Value = "Country"
    Worksheets("Sheet3").Cells(1, 1).Interior.Color = RGB(65, 105, 225)
    Worksheets("Sheet3").Cells(1, 2).Value = "City"
    Worksheets("Sheet3").Cells(1, 2).Interior.Color = RGB(65, 105, 225)
    Row = 2
    Col = 1
    For Each xParent In xEmpDetails.ChildNodes
        For Each xChild In xParent.ChildNodes
            Worksheets("Sheet3").Cells(Row, Col).Value = xChild.Text
            Col = Col + 1
        Next xChild
        Row = Row + 1
        Col = 1
    Next xParent
End Sub
 1
Author: Adnan Shahmir Ahmed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-01 20:44:17