XMLHTTP e caracteres especiais (por exemplo, acentos)
Estou usando o Microsoft.XMLHTTP via VBA para inserir o corpo de uma página da web. Ao fazer isso, caracteres como é são substituídos por "?" ou algo igualmente inútil.
Aqui está o código básico:
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "GET", ThisWebPage, False
objHTTP.setRequestHeader "Content-Type", _
"application/x-www-form-urlencoded; charset=UTF-8"
objHTTP.Send ("")
strResponse = objHTTP.responseText
Existe alguma maneira de recuperar a página com os caracteres especiais intacto
ota: Eu também tentei usar este cabeçalho de solicitação sem sucesso:objHTTP.setRequestHeader "Content-Type", "content=text/html; charset=iso-8859-1"
Desde já, obrigado
Soluçã
Graças ao Ben.Vineyard (e alguns superficialmente pesquisando no Google), sou capaz de extrair caracteres acentuados com o seguinte código:
' Create the XMLHTTP object
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
' Send the request
objHTTP.Open "GET", WhatWebPage, False
objHTTP.Send ("")
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
With BinaryStream
.Type = adTypeBinary
.Open
.Write objHTTP.ResponseBody
'Change stream type To binary
.Position = 0
.Type = adTypeText
'Specify charset For the source text (unicode) data.
.Charset = "iso-8859-1"
'Open the stream And get binary data from the object
strResponse = .ReadText
End With