2013-03-26 82 views

回答

1

Office AddIn可以在不触发防火墙问题的情况下发出HTTP请求(在默认配置中使用Windows防火墙),但在不触发防火墙问题的情况下无法侦听。

如果您正在向Word服务以外的用户提出请求,那么该服务可能会在监听端口时遇到防火墙问题。

Windows防火墙默认为blocks incoming requests。 Windows防火墙包含在所有版本的Windows XP SP2或更高版本中。

请参阅MSDN for more

此外,

Function GetRateCBR(dDate As Date) As String 
Dim sUrlRequest, intTry As Integer, _ 
    strResponse As String 
Dim oXMLHTTP As Object 
Dim oResponse As Object 

Set oResponse = CreateObject("MSXML2.DOMDocument") 

'Build URL for request 
sUrlRequest = _ 
    "http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=" _ 
    & Format(dDate, "dd.mm.yyyy") _ 
    & "&date_req2=" & Format(dDate, "dd.mm.yyyy") _ 
    & "&VAL_NM_RQ=" & "R" 

'Try to get a response, 10 tries 
intTry = 1 
Do Until intTry > 10 
    Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP") 
    oXMLHTTP.Open "GET", sUrlRequest, False 
    oXMLHTTP.send 
    If oXMLHTTP.Status = 200 Then 
     If oResponse.loadXML(oXMLHTTP.responseText) Then _ 
      Exit Do 
    End If 
    If Not oXMLHTTP Is Nothing Then oXMLHTTP.abort: _ 
     Set oXMLHTTP = Nothing 
    DoEvents 
    intTry = intTry + 1 
Loop 
If Not oXMLHTTP Is Nothing Then oXMLHTTP.abort: _ 
    Set oXMLHTTP = Nothing 
If intTry <= 10 Then 
    GetRateCBR = Mid$(oResponse.Text, 3) 
End If 
If Not oResponse Is Nothing Then oResponse.abort: _ 
    Set oResponse = Nothing 
End Function 

通过Access Blog

+0

感谢您的答复例如,你有怎样的例子设置在C#中?或者,使用VB编写MS Word插件是否很常见? – Jacky 2013-04-01 14:34:16

相关问题