[算表] 用VBA copy txt文件的問題

看板Office作者時間12年前 (2014/03/12 22:00), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
軟體: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

03/12 23:14, , 1F
Cells(i,1)= "'" & myBuf
03/12 23:14, 1F

03/12 23:42, , 2F
感謝!
03/12 23:42, 2F
文章代碼(AID): #1J86XWsd (Office)
文章代碼(AID): #1J86XWsd (Office)