Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help! Exporting report to HTML as one single HTML page

Status
Not open for further replies.

PerSvan

Technical User
Jul 5, 2002
4
SE
Is there anybody that know how to export a report to HTML, but not to many HTML-pages, I only want the result as one single continous HTML page.
 
this was written by : danvlas
in thread : 181-327708

I would do it like below(it's just an example, if you want table borders, colors and so on, you'll have to modify the code to insert tags in the appropriate places in your file)...
I tested it with a table 'Downloads'. Change the name to what you have and test it.

Sub myhtml()
Dim rst As DAO.Recordset
Dim i As Long
Dim j As Long
Dim fld As Field
Set rst = CurrentDb.OpenRecordset("Downloads")
'create/overwrite the original file
Open "C:\test.html" For Output As #1
'start with the html tag
Print #1, &quot;<html>&quot;
'body tag, you can insert whatever you want here
Print #1, &quot;<body>&quot;
With rst
.MoveFirst
'table tag
Print #1, &quot;<table>&quot;

'First row: table names
Print #1, &quot;<TR>&quot;
Print #1, &quot;<TD>Record number</TD>&quot; 'just to count the records
'print field names
For j = 0 To .Fields.Count - 1
Print #1, &quot;<TD>&quot; & .Fields(j).Name & &quot;</TD>&quot;
Next
'First row finished
Print #1, &quot;</TR>&quot;

'start looping through the recordset
Do Until .EOF
'evaluate each row of data
Print #1, &quot;<TR>&quot;

Print #1, &quot;<TD>&quot; & i + 1 & &quot;</TD>&quot; 'insert record counter
'find and output field values in current record
For Each fld In rst.Fields 'For j = 0 To .Fields.Count - 1
Print #1, &quot;<TD>&quot; & fld.Value & &quot;</TD>&quot;
Next

'finish row
Print #1, &quot;</TR>&quot;
i = i + 1 'record counter
'move to next record
.MoveNext
Loop
'close recordset
.Close
End With
Print #1, &quot;</table>&quot;
Set rst = Nothing

'end with the body
Print #1, &quot;</body>&quot;

'html end here
Print #1, &quot;</html>&quot;

'close new html file
Close #1
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top