在excel中定义宏如下:
- VB code
Sub opost() Set objhttp = CreateObject("MSXML2.ServerXMLHTTP") Dim URL Dim data URL = "http://127.0.0.1/test/test.asp" objhttp.Open "POST", URL, False 'objhttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" objhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objhttp.send ("id=1") data = objhttp.responseText Cells(1, 1).Value = dataEnd Sub
asp页面源码如下
- VBScript code
<% dim id id = request.Form("id") response.write id%>
应该是很直观的http请求。
但问题是,如果我提交给页面的数据包含中文,宏运行就会出错。提示:系统错误C00CC4514。
另外,我也需要让页面返回一些比较友好的中文信息。
请大家帮忙看看。谢谢!
------解决方案--------------------------------------------------------
可以在asp里面看到id是怎样的值吗?乱码还是编码过的?
伺服器回应是否需要编一下码?
Content-Type:text/html; charset=utf-8
另客户端好像都用
Msxml2.XMLHTTP
我也不知道纯猜测的