对于二进制的文件,我们可以通过vba代码转为文本文件。这里以dxf为例,
代码如下:
Sub ConvertBinaryToText()Dim fs As Object ' FileSystemObjectSet fs = CreateObject("Scripting.FileSystemObject")Dim binaryFilePath As String ' 二进制文件路径binaryFilePath = "D:\**\.dxf"Dim textFilePath As String ' 输出文本文件路径textFilePath = "D:\**\1.txt"Dim inputStream As Object ' 读取二进制文件流Set inputStream = fs.OpenTextFile(binaryFilePath)Dim outputStream As Object ' 写入文本文件流Set outputStream = fs.CreateTextFile(textFilePath)Do Until inputStream.AtEndOfStreamDim line As String ' 每行数据line = inputStream.ReadLine' 在这里处理每行数据,如果需要特定格式或者其他操作' 将处理后的结果写入到文本文件outputStream.WriteLine lineLoop' 关闭文件流inputStream.CloseoutputStream.CloseMsgBox "已成功将二进制文件转换为文本!"
End Sub
结果如下: