作者Cidolfas ()
看板Office
標題[算表] 用VBA copy txt文件的問題
時間Wed Mar 12 21:59:57 2014
軟體:Excel
版本:2007
目前正使用某處找到的程式碼copy資料到excel,
但是有一個問題,若是txt裡面起始的位置出現
=(等於)
這個VBA就會失效,
請問該如何解決?謝謝。
Sub ReadTxt2()
Dim myTxtFile As String, myFNo As Integer
Dim myBuf As String
Dim i As Integer
Application.ScreenUpdating = False
myTxtFile = ActiveWorkbook.Path & "\M.txt"
Worksheets("文件類型").Activate
myFNo = FreeFile '取得可使用的檔案代碼
Open myTxtFile For Input As #myFNo
Do Until EOF(myFNo)
Line Input #myFNo, myBuf
i = i + 1
Cells(i, 1) = myBuf '將資料置入儲存格內
Loop
Close #myFNo
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.251.225.44
推 Catbert:Cells(i,1)= "'" & myBuf 03/12 23:14
→ Cidolfas:感謝! 03/12 23:42