cod*_*000 3 excel file-io vba excel-vba
我有一个简单的Excel 2007宏,它逐行读取文本文件并显示输出.
这个宏在逗号上打破了.我希望它只是简单地读取整个线路在一个carrage返回.
我究竟做错了什么?
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
Run Code Online (Sandbox Code Playgroud)
这是一个示例文本文件:
1 blahblahblabh
2 blah,blahblah
Run Code Online (Sandbox Code Playgroud)