📜  vba 获取文本文件内容 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:54.056000             🧑  作者: Mango

代码示例1
' Returns an array of lines from a text file
Function FileInArray() As Variant
    Dim fileSO As Object, textFile As Object, content
    On Error GoTo CExit
    Set fileSO = CreateObject("Scripting.FileSystemObject")
    Set textFile = fileSO.OpenTextFile("C:\temp\file.txt", 1)
    content = textFile.ReadAll
    FileInArray = Split(content, vbNewLine)
    textFile.Close
CExit:
End Function