我可以通过excel打开记事本,但不知道如何复制文本。
我也在谷歌尝试过,但无法获得任何相关的好信息。
通过vba打开记事本文件“TESTFILE.txt”,选择所有数据,复制并粘贴到excel中:)
如果您询问vba,请这样做
Sub ImportText()
Dim Text
Dim i As Long
Application.ScreenUpdating = False
'put your own path below
Open ActiveWorkbook.Path & "\MYFILE.txt" For Input As #1
i = 1
Do While Not EOF(1) ' Loop until end of file.
Input #1, Text
Range("a" & i) = Text
i = i + 1
Loop
Close #1
End Sub
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\Users\Kalim\Desktop\Zeeshan\zeeshan.txt",1)
Dim strLine
do while not objFileToRead.AtEndOfStream
strLine = objFileToRead.ReadLine()
msgbox(strLine)
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.open("C:\Users\Kalim\Desktop\Zeeshan\test3.xlsx")
a=Split(strLine,":")
b=ubound(a)
For i=0 to b
If a(0)="50" Then
objExcel.Cells(3,4).Value = a(1)
End If
Next
objWorkbook.Save
objWorkbook.Close
msgbox("Execution completed")
loop
objFileToRead.Close