reading entire text file using vba

前端 未结 8 1283
暗喜
暗喜 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条回答
  •  感动是毒
    2020-12-06 11:07

    Sub LoadFile() ' load entire file to string
    ' from Siddharth Rout
    ' http://stackoverflow.com/questions/20128115/
        Dim MyData As String
        Open "C:\MyFile" For Binary As #1
        MyData = Space$(LOF(1)) ' sets buffer to Length Of File
        Get #1, , MyData ' fits exactly
        Close #1
    End Sub
    

提交回复
热议问题