Function ReadText(FileName As String) As String With CreateObject("ADODB.Stream") .Type = 2 .Mode = 3 .Open .LoadFromFile FileName .Charset = "UTF-8" '根据需要也可以选择Unicode .Position = 2 ReadText= .ReadText .Close End With End Function
Function ReadText(FileName As String) As String Dim Fso As New FileSystemObject Dim Fil As TextStream Set Fil = Fso.OpenTextFile(FileName, ForReading, False, TristateTrue) ReadText= Fil.ReadAll End Function
标签:Function,VBA,End,读取,ReadText,FileName,文本文件,Fil,String From: https://www.cnblogs.com/sonycat/p/sonycat_ReadText.html