S
shy1162
This imports binary code and converts to hex numbers. It has worked
flawlessly for years. Now in a excel 2003 Japanese language version,
not so flawlessly. It gets confused occasionally (5% error) and reads
two bits instead of one. Is there a way to turn off the Double-Byte
capability of Japanese language versions of excel? Can I add something
to the macro to force a single byte read?
02 0E 89 20 21 2F 02 01 Should look like
02 0E 8445 21 2F 02 01 I get this error
_________________________________________________________
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(FileNameWithPath)
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
ColumnCount = 3
RowCount = Sheets("Sheet2").Range("N5").Value + 1 'Offset
RowCount = Val("&h" & RowCount & "&")
Do While ts.atendofstream = False 'Loop to fill column with HEX
numbers
DecimalByte = Asc(ts.Read(1))
HexByte = Hex(DecimalByte)
Cells(RowCount, ColumnCount) = HexByte
RowCount = RowCount + 1
Loop
ts.Close
flawlessly for years. Now in a excel 2003 Japanese language version,
not so flawlessly. It gets confused occasionally (5% error) and reads
two bits instead of one. Is there a way to turn off the Double-Byte
capability of Japanese language versions of excel? Can I add something
to the macro to force a single byte read?
02 0E 89 20 21 2F 02 01 Should look like
02 0E 8445 21 2F 02 01 I get this error
_________________________________________________________
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(FileNameWithPath)
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
ColumnCount = 3
RowCount = Sheets("Sheet2").Range("N5").Value + 1 'Offset
RowCount = Val("&h" & RowCount & "&")
Do While ts.atendofstream = False 'Loop to fill column with HEX
numbers
DecimalByte = Asc(ts.Read(1))
HexByte = Hex(DecimalByte)
Cells(RowCount, ColumnCount) = HexByte
RowCount = RowCount + 1
Loop
ts.Close