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!

Output to HTML from Access

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
US
In Access, there are two ways you can output a separate HTML file for each record:[ul]
[li]Create a report that displays one record per page, and then output the report as an HTML file.[/li]
[li]Use the PRINT statement in VBA to enumerate through a recordset, format each field as HTML tags, and then output each record to an HTML file.[/li]

[ul]
[li]How do I use *PRINT statement in VBA?[/li]
[li]How can I format(Font/Bold/Underline/Spacing) in VBA and pass it to the body of an Email?[/li][/ul][/ul]

I am trying to use data (from a MS Access Form and VBA(SQL) to build and load the body of an Email with a formatted report. But my various attempts have not worked [sad]

*Tried:*
Code:
DoCmd.SendObject OutputFormat:=acFormatHTML, to:=ToEmailsListTxt, Subject:=SubjectLineTxt, MessageText:=BodyOfEmailTxt, EditMessage:=EditMessageTxt
[COLOR=red]'Resulting in no formatting, left justified ugly report[/color]

*Tried:*
Code:
[COLOR=red]'~Create temp HTML work area --[/color]
TempHtmlWorkArea = Environ("Temp") & "\InvoiceRptTemp.txt"
If Len(Dir(TempHtmlWorkArea)) > 0 Then
       Kill TempHtmlWorkArea
End If
       DoCmd.OutputTo acOutputReport, strReportName, acFormatHTML, TempHtmlWorkArea
intFile = FreeFile

[COLOR=red]'Open TempHtmlWorkArea For Input As #intFile[/color]
Open TempHtmlWorkArea For Input As #intFile
[COLOR=red]'Load temp HTML work area --[/color]
Do While Not EOF(intFile)
     Line Input #intFile, strLine
     BodyOfEmailTxt = BodyOfEmailTxt & strLine
Loop
   Close #intFile
   DoCmd.SendObject acSendNoObject, "", acFormatHTML, strTo, , , strSubject, BodyOfEmailTxt
[COLOR=red]'Resulting in formatted but only first page of report.[/color]

Appreciative for any help/advice,


Alan
[smurf]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top