I have an HTML file that I wrote to create a string. The file is called MyHTMLfile
and it is located in U:\temp
.
How can I easily (and with as little as possible computing time) copy the entire string from HTML to Range("IV" & RowCount)
?
I have an HTML file that I wrote to create a string. The file is called MyHTMLfile
and it is located in U:\temp
.
How can I easily (and with as little as possible computing time) copy the entire string from HTML to Range("IV" & RowCount)
?
If you want the entire file to be put in a single cell...
With CreateObject("Scripting.FileSystemObject")
Range("IV" & RowCount) = .OpenTextFile("u:\temp\myhtmlfile.htm").ReadAll()
End With
This is assuming your myHtmlFile
has an extension of .htm
. Change as needed.
How's something like this:
Sub test21()
'Thanks to http://stackoverflow.com/questions/11528694/read-parse-text-file-line-by-line-in-vba
Dim FileNum As Integer, i As Integer
Dim DataLine As String
FileNum = FreeFile()
Open "U:\Temp\myHTMLFile.html" For Input As #FileNum
i = 1 ' This is where you want to set your `RowCount`.
While Not EOF(FileNum)
Line Input #FileNum, DataLine ' read in data 1 line at a time
Range("IV" & i).Value = DataLine
i = i + 1
Wend
End Sub