Word 宏指令CVX

Sub ChangeTxtToExl()
Dim fso, Tx As Object
Dim arr As Variant
Dim line As String
Dim i As Integer


Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject") '创建FSO对象
Set Tx = fso.OpenTextFile("D:\MATLAB\鼠标情绪\hook_log.txt") '在此处修改成要导入TXT文档的实际路径
i = 1
ThisWorkbook.Sheets(1).Activate '转换结束后,应先保存为帯宏的工作簿文件(方便以后再次修改)。
Do While Tx.AtEndOfStream <> True '再另存为工作簿文件,在之前还可以进行一些格式优化处理,当然也可以使用vba代码来实现
line = Tx.ReadLine
arr = Split(line)
Cell(1, i).Resize(UBound(arr), 1, 1) = Application.Transpose(arr)
i = i1
Loop
Tx.Close
Application.ScreenUpdating = True
Set fso = Nothing
End Sub

你可能感兴趣的:(Word 宏指令CVX)