ACE/Jet OLEDB URL source possible?

Stang70Fastback

Registered User.
Local time
Today, 10:37
Joined
Dec 24, 2012
Messages
132
Hello all. I am trying to import an HTML table into Access. Someone suggested I use ACE/Jet, which I got working with the following code:

Private Sub Command0_Click()

Const LocalTableName = "EMPLOYEES"
Dim con As Object, rstHtml As Object, fld As Object, _
cdb As DAO.Database, rstAccdb As DAO.Recordset, _
recCount As Long

Set con = CreateObject("ADODB.Connection")
con.Open _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:\Users\Desktop\EMPLOYEES.htm;" & _
"Extended Properties=""HTML Import;HDR=YES;IMEX=1"";"
Set rstHtml = CreateObject("ADODB.Recordset")
rstHtml.Open "SELECT * FROM [EMPS_VIEW_BUS_TRAINING Report]", con

Set cdb = CurrentDb
cdb.Execute "DELETE FROM [EMPLOYEES]", dbFailOnError
Set rstAccdb = cdb.OpenRecordset("EMPLOYEES", dbOpenTable)

recCount = 0
Do While Not rstHtml.EOF
recCount = recCount + 1
rstAccdb.AddNew
For Each fld In rstHtml.Fields
rstAccdb.Fields(Trim(fld.Name)).Value = Trim(fld.Value)
Next
Set fld = Nothing
rstAccdb.Update
rstHtml.MoveNext
Loop

rstAccdb.Close
Set rstAccdb = Nothing
Set cdb = Nothing

rstHtml.Close
Set rstHtml = Nothing
con.Close
Set con = Nothing

Debug.Print recCount & " record(s) imported"

End Sub

However, the original goal was for this to pull straight from the web page - not from a copy of the web page saved locally. Does anyone know if this is possible? I tried the obvious use of a URL rather than a local directory, but that throws a "read only" error suggesting an unrecognized file extension. Is it possible to do what I am trying to do?
 
Now I think I've seen something like this done before where the Data Source points to the URL of the html file. Try changing the Data Source to the URL of the html file, something like this:
Code:
"Data Source=http://www.sourceofhtml.com/thetable.html"
You can also try other drivers like JET OLEDB as well.
 
Ok. Sorry to drag this thread up from the dead! After several months I've finally "finished" this database with the exception of this one piece, and I'm ready to devote all of my attention to making this happen.

I did try changing the link to the URL as vbaInet suggested, but that does not work, as stated in my original post. As far as Uncle Gizmo's question is concerned, what would be the benefit of this? I'd have to talk to someone in the IT department and find out if I could make that happen, but I'm not familiar enough with this stuff to know why that would be better?
 
DIY solution is to parse it yourself. See my post about guide in web section
 

Users who are viewing this thread

Back
Top Bottom