我正在尝试将数据从Word文档发送到网页。我找到了一些代码,将其粘贴到新模块中并保存了。运行它时,我收到“编译错误,未定义用户定义的类型”
我的代码:
Sub http()
Dim MyRequest As New WinHttpRequest
MyRequest.Open "GET", _
"http://www.google.com"
' Send Request.
MyRequest.Send
'And we get this response
MsgBox MyRequest.ResponseText
End Sub
最佳答案
避免必须选择库的潜在替代方法是使用对象,即
Sub http()
Dim MyRequest As Object
Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
MyRequest.Open "GET", _
"http://www.google.com"
' Send Request.
MyRequest.Send
'And we get this response
MsgBox MyRequest.ResponseText
End Sub