我正在使用Excel 2003 &我在宏中有以下代碼。VBA ReadLine從文件讀取時出錯
Dim fs, a, retstring
Set fs = CreateObject("scripting.filesystemobject")
Set a = fs.OpenTextFile("C:\file.txt", ForReading, False)
Do While a.AtEndofStream <> True
retstring = a.ReadLine
Loop
a.Close
當我執行這一點,就說明
"Runtime Error:5"
Invalid Procedure Call or argument at OpenTextFile
定義常量ForReading = 1.查看代碼[here](http://stackoverflow.com/questions/1722196/what-is-dim-fso-myfile-filename-textline-in-vba)。 – deusxmach1na
@ deusxmach1na:謝謝你。有用。請把它作爲答案,以便我可以接受它。 – logan