Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output unicode fields to an html file 1

Status
Not open for further replies.

elac

Technical User
Jul 9, 2002
14
0
0
BE
I want to generate an html page from an access table using a VBA procedure. One of the fields contains sometimes Cyrillic characters. I can see them correctly when I consult the table with Access. When I output them to the html file (print #1, MyTable.Fields("Label")), they are converted to "???". Thanks for your help.
 
elac,
[tt]Print #[/tt] does ASCII, you will need Unicode to output Cyrillic. Here are a couple of examples using different [tt]Stream[/tt] objects.
Code:
Sub WriteFSO()
  'Uses a reference to Microsoft Scripting Runtime (scrrun.dll)
  Dim objFSO As Scripting.FileSystemObject
  Dim objTS As Scripting.TextStream
  Set objFSO = New FileSystemObject
  '[b]TristateTrue[/b] sets the file to Unicode
  Set objTS = objFSO.OpenTextFile("C:\FSO.txt", _
    ForWriting, _
    True, _
    [b]TristateTrue[/b])
  With objTS
    .WriteLine GoodDay
    .Close
  End With
  Set objTS = Nothing
  Set objFSO = Nothing
End Sub

Sub WriteSDOStream()
  'Uses a reference to Microsoft ActiveX Data Objects 2.5 (msado25.tlb)
  Dim strmOut As ADODB.Stream
  Set strmOut = New ADODB.Stream
  With strmOut
    .Type = adTypeText
    .Charset = "utf-8"
    .Open
    .WriteText GoodDay, adWriteLine
    .SaveToFile "C:\ADO.txt", adSaveCreateOverWrite
    .Close
  End With
  Set strmOut = Nothing
End Sub

Supporting function that creates some Russian.

Code:
Public Function GoodDay() As String
  Dim bytCyrillic(23) As Byte
  bytCyrillic(0) = 69
  bytCyrillic(1) = 4
  bytCyrillic(2) = 62
  bytCyrillic(3) = 4
  bytCyrillic(4) = 64
  bytCyrillic(5) = 4
  bytCyrillic(6) = 62
  bytCyrillic(7) = 4
  bytCyrillic(8) = 72
  bytCyrillic(9) = 4
  bytCyrillic(10) = 56
  bytCyrillic(11) = 4
  bytCyrillic(12) = 57
  bytCyrillic(13) = 4
  bytCyrillic(14) = 32
  bytCyrillic(15) = 0
  bytCyrillic(16) = 52
  bytCyrillic(17) = 4
  bytCyrillic(18) = 53
  bytCyrillic(19) = 4
  bytCyrillic(20) = 61
  bytCyrillic(21) = 4
  bytCyrillic(22) = 76
  bytCyrillic(23) = 4
  GoodDay = bytCyrillic
End Function

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Dear CautionMP,

It's working. Great !
Thanks a lot.

elac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top