reading entire text file using vba

前端 未结 8 1284
暗喜
暗喜 2020-12-06 11:03

I\'m trying to read a text file using vba. I tried the below code

Open \"C:\\tester.txt\" For Input As #1
Worksheets(\"UI\").Range(\"H12\").Value = Input$(LO         


        
8条回答
  •  旧时难觅i
    2020-12-06 11:12

    To read line by line:

    Public Sub loadFromFile(fullFilename As String)
    
        Dim FileNum As Integer
        Dim DataLine As String
    
        FileNum = FreeFile()
        Open fullFilename For Input As #FileNum
    
        While Not EOF(FileNum)
            Line Input #FileNum, DataLine
            Debug.Print DataLine
        Wend
    End Sub
    

提交回复
热议问题