用户定义类型未定义 windows 10
User-defined Type not defined windows 10
我有这个从天气 API 获取天气信息的子。它适用于 Windows 7 台计算机,但不适用于 Windows 10。我收到 "User-defined type not defined" 错误并突出显示 Dim Req As New XMLHTTP
行。我已尝试将 DOMDocument 更改为 DOMDocument60,并且我已尝试确保已选中 MicrosoftXML V6.0。
Public Sub GetWeather(APIurl As String, sted As String)
Dim i As Integer
Dim ws As Worksheet: Set ws = ActiveSheet
Dim city As String
Dim omraade As String
Dim Req As New XMLHTTP
Dim Weather As IXMLDOMNode
Dim wShape As Shape
Dim thisCell As Range
Dim Resp As New DOMDocument60
i = 0
omraade = ""
omraade = sted
Select Case omraade
Case "Area1"
i = 4
Case "Area2"
i = 6
Case "Area3"
i = 8
Case Else
Exit Sub
End Select
Req.Open "GET", "" & APIurl & "", False
Req.Send
Resp.LoadXML Req.responseText
For Each Weather In Resp.getElementsByTagName("current_condition")
Set thisCell = ws.Range(Cells(2, i), Cells(2, i))
Set wShape = ws.Shapes.AddShape(msoShapeRectangle, thisCell.Left, thisCell.Top, thisCell.Width, thisCell.Height)
wShape.Fill.UserPicture Weather.ChildNodes(4).Text 'img
Cells(3, i).Value = "" & Weather.ChildNodes(7).Text * 0.28 & " m/s" 'windspeedkmph
Cells(4, i).Value = Weather.ChildNodes(9).Text 'Direction
Cells(5, i).Value = Weather.ChildNodes(1).Text & " C" 'observation time
Next Weather
End Sub
有什么想法吗?
在工具、参考中正确引用了 Microsoft XML v6.0 库,适当的调用是,
Dim req As New MSXML2.XMLHTTP60
我在“工具”、“参考”中从 XML 6.0 更改为 XML 3.0,现在可以同时使用 Windows 7 和 Windows 10...
我有这个从天气 API 获取天气信息的子。它适用于 Windows 7 台计算机,但不适用于 Windows 10。我收到 "User-defined type not defined" 错误并突出显示 Dim Req As New XMLHTTP
行。我已尝试将 DOMDocument 更改为 DOMDocument60,并且我已尝试确保已选中 MicrosoftXML V6.0。
Public Sub GetWeather(APIurl As String, sted As String)
Dim i As Integer
Dim ws As Worksheet: Set ws = ActiveSheet
Dim city As String
Dim omraade As String
Dim Req As New XMLHTTP
Dim Weather As IXMLDOMNode
Dim wShape As Shape
Dim thisCell As Range
Dim Resp As New DOMDocument60
i = 0
omraade = ""
omraade = sted
Select Case omraade
Case "Area1"
i = 4
Case "Area2"
i = 6
Case "Area3"
i = 8
Case Else
Exit Sub
End Select
Req.Open "GET", "" & APIurl & "", False
Req.Send
Resp.LoadXML Req.responseText
For Each Weather In Resp.getElementsByTagName("current_condition")
Set thisCell = ws.Range(Cells(2, i), Cells(2, i))
Set wShape = ws.Shapes.AddShape(msoShapeRectangle, thisCell.Left, thisCell.Top, thisCell.Width, thisCell.Height)
wShape.Fill.UserPicture Weather.ChildNodes(4).Text 'img
Cells(3, i).Value = "" & Weather.ChildNodes(7).Text * 0.28 & " m/s" 'windspeedkmph
Cells(4, i).Value = Weather.ChildNodes(9).Text 'Direction
Cells(5, i).Value = Weather.ChildNodes(1).Text & " C" 'observation time
Next Weather
End Sub
有什么想法吗?
在工具、参考中正确引用了 Microsoft XML v6.0 库,适当的调用是,
Dim req As New MSXML2.XMLHTTP60
我在“工具”、“参考”中从 XML 6.0 更改为 XML 3.0,现在可以同时使用 Windows 7 和 Windows 10...