I just need the header from the first file of html folder, it can be ignored from rest all files since we will append data from each file one below another. Below is the snapshot highlighting the header row.
Also I added the reference to Microsoft Forms 2.0 Object Library, it wasn't appearing in the references in excel 2010 but i used the browse button and selected it from C:\WINDOWS\system32\FM20.DLL and then it started appearing in the references but when I run the code nothing happens. It doesn't show any error as well.
Code:Sub GetHTMLFiles () Dim doc As MSHTML.HTMLDocument, d As DataObject, htm As String Set d = New DataObject Set doc = CreateObject("htmlfile") fpath = "C:\users\abhy\desktop\htmldatafiles\" fpath = "C:\users\abhy\Appdata\Local\Temp" f = Dir(fpath & "*.htm") Do While f <> "" Open fpath & f For Input As 1 htm = Input(LOF(1), #1) Close 1 doc.body.innerHTML = htm Set t = doc.getElementsByTagName("table")(0) d.Clear d.settext t.innerText d.PutInClipboard rw = Cells(Rows.Count, 1).End(xlUp).Row + 1 If rw = 2 Then rw = 1 Cells(rw, 1).PasteSpecial If rw = 1 Then 'fix headers Else ' delete headers hrows = 12 ' may need adjustment Cells(rw, 1).Resize(hrows).EntireRow.Delete End If f = Dir Loop End Sub




Reply With Quote
