[英]Excel 2007 VBA Macro reading a text file line by line how do I stop delimiting on a comma (,)
我有一個簡單的Excel 2007宏,它逐行讀取文本文件並顯示輸出。
這個宏在逗號上打破了。 我希望它只是簡單地讀取整個線路在收獲回報。
我究竟做錯了什么?
Sub Directory()
Dim strFileName As String
Dim strDirectory As String
Dim intFileKey As Integer
Dim strLine As String
strDirectory = "C:\Documents and Settings\e1009028\My Documents\embosstest"
ChDir (strDirectory)
strFileName = Dir("*.txt")
Do While Len(strFileName) > 0
intFileKey = FreeFile
Open strFileName For Input As intFileKey
Do While Not EOF(intFileKey)
Input #intFileKey, strLine
MsgBox Mid(strLine, 1, 10)
Loop
strFileName = Dir
Loop
End Sub
這是一個示例文本文件:
1 blahblahblabh
2 blah,blahblah
有關更現代的解決方案,請查看FileSystemObject ,尤其是OpenTextFile 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.