使用以下函数,函数参数为文本文件路径
Function readText(filepath As String) As String Dim fso Dim f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(filepath) readText = f.ReadAllEnd Function
示例 str=readText("d:\111.txt")