2017-09-29 11 views
3

16進コードを持つ.logファイルとして出力されるデータを記録するために、ハンナセンサー計測器を使用しています。 次に、このデータをExcel形式(数字&文字&の特殊文字)に変換するハンナソフトウェア(本機に付属)を使用します。 私はそれがどのようにしているか知りたいのですが、可能であればソフトウェアなしで自分でやっていますか?ファイルを変換するために16進ファイルを変換する

ファイルは、次のようになり、その拡張子は.logに

4d65 7465 720a 3230 3137 3039 3139 0000 
c1fb 5321 ffff 01fc 1fc8 ffff f4ff f92d 
0dc3 58ff 4a00 0000 0000 735a 0081 6101 
a242 0000 0000 0000 0000 0000 0000 0000 
0000 0000 0000 0000 0000 003d 3950 82cc 
0940 08b4 3088 c2fb 5321 ffff 01fc 1fc8 
ffff f4ff 0b2e 0dae 58ff 4a00 0000 0000 
a85a 00a8 6101 1143 0000 0000 0000 0000 
0000 0000 0000 0000 0000 0000 0000 0000 
. 
. 
. 
continued 
+0

プログラミングの質問は何ですか?その外観から、あなたはハードウェアの質問をしています。センサーはXをどのように測定し、どのようにこの情報を保存し、それが.logから.xlsxに変換されるかを示します。 –

+0

情報は.logファイルとして保存され、このソフトウェアを使用してExcel表に変換されます。私はそれが.logを.xlsxに変換する方法を知らない。私はそれを見つけてそれを自分自身に優秀にしようとしています。 –

答えて

1

あるような何か試してみてください:プロセスはどちらか、その後.LOGファイルをインポートする作業と

Sub JustOneFile() 
    Dim s As String, i As Long 

    i = 1 
    Close #1 
    Open "C:\TestFolder\james.log" For Input As #1 

    Do Until EOF(1) 
     Line Input #1, s 
     Cells(i, 1) = s 
     i = i + 1 
    Loop 

    Close #1 

    Columns("A:A").TextToColumns Destination:=Range("B1"), DataType:=xlFixedWidth, _ 
     FieldInfo:=Array(Array(0, 2), Array(4, 2), Array(9, 2), Array(14, 2), Array(19, 2), _ 
     Array(24, 2), Array(29, 2), Array(34, 2)), TrailingMinusNumbers:=True 
End Sub 

enter image description here

0

をすべてのセルをループして個別に変換するか、データブロック全体をバリアント配列に格納し、それらを変換して変換したvalを返すワークシートに追加してください。後者の変換方法が推奨されます。

Option Explicit 

Sub wqewqw() 
    Dim hxwb As Workbook 
    Dim i As Long, j As Long, vals As Variant 

    Workbooks.OpenText Filename:="%USERPROFILE%\Documents\hex_2_excel.log", _ 
     Origin:=437, StartRow:=1, DataType:=xlFixedWidth, TrailingMinusNumbers:=True, _ 
     FieldInfo:=Array(Array(0, 2), Array(4, 2), Array(9, 2), Array(14, 2), _ 
         Array(19, 2), Array(24, 2), Array(29, 2), Array(34, 2)) 
    With ActiveWorkbook 
     With .Worksheets(1) 
      vals = .Cells(1, "A").CurrentRegion.Cells 
      For i = LBound(vals, 1) To UBound(vals, 1) 
       For j = LBound(vals, 2) To UBound(vals, 2) 
        vals(i, j) = Application.Hex2Dec(vals(i, j)) 
       Next j 
      Next i 
      With .Cells(1, "A").Resize(UBound(vals, 1), UBound(vals, 2)) 
       .NumberFormat = "General" 
       .Value = vals 
      End With 
     End With 
    End With 

End Sub 

enter image description here

関連する問題