PDA

View Full Version : Unicode in Excel-Cells



dherr
10-18-2015, 08:18 AM
Hi,
I do the following:
In a Website I mark a table with data (some data in Unicode characters), then copy this to the clipboard, then paste it into a Excel sheet.
All goes right, also the Unicode characters are in the cells.

Now the problem:
I try to automate this via VBA. I read the source code of the Website and extract the table data. The extraction works via:
Dim src as String
I use now a function:

Public Function GetPageSourceCode(url As String) As String
' tools > references > select Windows Win Http Services 5.1
' to get data from the url we need to create a win Http object
Dim myHttp As New WinHttpRequest
With myHttp
.Open "GET", url, False 'open the url
.Send ' send request
GetPageSourceCode = .ResponseText
End With
End Function
and
src = GetPageSourceCode(myUrl)
Now the Unicode characters are gone!!!
I can insert the data into the cells with wrong characters only...

What can I do to get the right Unicode characters in my Excell cells?

Regards
Dietrich

snb
10-18-2015, 09:14 AM
Did you try


.setRequestHeader("Content-Type", "text/UTF-8")

dherr
10-18-2015, 10:05 AM
Did you try


.setRequestHeader("Content-Type", "text/UTF-8")

No, but I will try it now.
Thanks for your fast answer!
Dietrich

dherr
10-19-2015, 01:52 AM
Hi,
I tried it with this code now:
Public Function GetPageSourceCode(url As String) As String
' tools > references > select Windows Win Http Services 5.1
' to get data from the url we need to create a win Http object
Dim myHttp As New WinHttpRequest
With myHttp
.Open "GET", url, False 'open the url
.SetRequestHeader "Content-Type", "text/UTF-8"
.Send ' send request
GetPageSourceCode = .ResponseText
End With
End Function
but with no success...

I also have in use the Microsoft Forms 2.0 Library. The Textbox shows not all Unicode characters...

Dietrich