import many files with long text

R

Rafael T

Hello

I do not know much about access but this is my problem

I have about 300 html files with some data that needs to be inside a database. The data is formatted in table so that access can import a file at a time. I can import one by one but that will take me forever.

I tried with a script to import using sql but it fail because the file contains large quantities of text which may include quotes, and xml tags as these html files are/were my sample code library.

Is there a way to automate the import of html files?

thanks
 
J

John Nurick

Hi Rafael,

Are you trying to import each HTML file into a Memo field in records
in an Access table, or are you trying to import data from HTML tables
into corresponding Access tables?
 
J

John Nurick

If you can import one of the HTML files by calling
DoCmd.TransferText acImportHTML
it should be possible to import them all by using something like this
(based on code originally posted by Joe Fallon; errors my own<g>):

Sub ImportAllHTMLFiles()
'procedure to import all files in a directory and delete them.
'assumes they are all well-formed HTML files containing
'a table named "XXX"

Dim strFile As String

ChDir("c:\MyFiles")
strFile = Dir("*.html")
Do While Len(strFile) > 0
DoCmd.TransferText acImportHTML, , "AccessTableName", _
"c:\MyFiles\" & strfile, True, "XXX"

'delete the file after import
'(consider moving it to another folder instead.)
Kill "c:\MyFiles\" & strfile

'get name of next file
strfile = Dir()
Loop

End Sub
 
J

John Nurick

Rafael,

IIRC it uses the contents of the table's <CAPTION> tag if there is
one, otherwise of its <TITLE> tag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top