Results 1 to 2 of 2
  1. #1
    broodmdh is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    7

    Problems exporting to HTML

    We have a db with a report that I want to export to HTML. We need a single html document containing a table free of formatting (which will be applied later). Is this possible? I know that exporting to HTML directly gives me 100+ separate files, which is no good. I've tried exporting to Excel 2010 and from there exporting to HTML, but the memo fields get cut off (some are quite long). Any suggestions? I can try to remove the formatting manually after the export, but I've yet to manage an export that doesn't throw every row into it's own table or divide the report up into a ridiculous number of files.

  2. #2
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Well I will start by saying that I am not familiar with coding in HTML. However, I do have a module that generates an XML document for me by writing to a text file and I would think you could do the same thing for an HTML output. You could use a DAO Recordset to gather the data you wish to export (you can use the same SQL statement your report is based on) and simply include the HTML code and the outputs in a series of TextFile.WriteLine commands. Below is a snippet of code that is basically what I use to generate my XML but I've swapped out my XML header for some basic HTML code to give you an idea of how you might format it.

    Code:
    Sub ExportXML()
    Dim rst As DAO.Recordset, fs, TextFile, strSQL As String
        Set fs = CreateObject("Scripting.FileSystemObject")
        Set TextFile = fs.CreateTextFile(myPath & myFileName.xml") 
    
        strSQL = 'Your report SQL statement goes here
        Set rst = CurrentDb.OpenRecordset(strSQL)
    ' Generating your HMTL code
    TextFile.WriteLine("<!DOCTYPE html>")
    TextFile.WriteLine("<html>")
    TextFile.WriteLine("<body>")
    Do Until rst.EOF
        TextFile.WriteLine("<p> & rst![YourFields] & "</p>")
    Loop
    
    rst.Close
    Set rst = Nothing
    Hope this helps!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. HTML and VBA
    By tylerg11 in forum Forms
    Replies: 1
    Last Post: 08-23-2012, 05:53 PM
  2. Exporting to HTML Trouble
    By starhawk85 in forum Import/Export Data
    Replies: 2
    Last Post: 05-03-2012, 06:06 PM
  3. HTML Editor
    By mystifier in forum Forms
    Replies: 3
    Last Post: 11-11-2010, 05:51 AM
  4. Exporting a query to HTML
    By Remster in forum Access
    Replies: 8
    Last Post: 09-10-2010, 04:52 PM
  5. HTML E-mail Using VBA
    By graviz in forum Programming
    Replies: 1
    Last Post: 12-09-2009, 08:52 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums