D
DBenedict
I have a small report (2" x 5" when printed) that when opened, shows the
current records in a form. I have to forward the report to others via email.
Instead of an attaching the report, I want to display the report as the body
of the Outlook email. The small 2x5" report visible in the email.
I'll use a button on the form to Open Outlook and output the report.
A previous attempt got Outlook to open and a brief screen message saying
"outputting report to ..." and then nothing. Just an open email with
nothing in the body.
After trying a few other things that didn't work, I stopped with this
attached to the button.
Private Sub SendMessage_Click()
ap_CreateOLMailItem
End Sub
I have this saved in the module.
Option Compare Database
Option Explicit
Public olkApp As Outlook.Application
Public olkNameSpace As Outlook.NameSpace
---------------------------------------------------
Sub ap_CreateOLMailItem()
Dim objMailItem As Outlook.MailItem
Dim myReport As Report
myReport.NAME = "Audit Results"
Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI")
Set objMailItem = olkApp.CreateItem(olMailItem)
With objMailItem
DoCmd.OutputTo acOutputReport, myReport, acFormatHTML,
CurrentProject.Path & "\myReport.html"
.Display
End With
Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
End Sub
"Audit Results" is the name of the report I want to insert it into the body.
I have read several posts of similar content, but as always, I want to do
things differently. I tried to piece code together for the parts that I want.
I have had numerous errors and for each I overcome, there is another.
I'd get errors here (myReport.NAME = "Audit Results") and here
(DoCmd.OutputTo acOutputReport, myReport, acFormatHTML, CurrentProject.Path &
"\myReport.html")
Any suggestions to get me on the right track?
current records in a form. I have to forward the report to others via email.
Instead of an attaching the report, I want to display the report as the body
of the Outlook email. The small 2x5" report visible in the email.
I'll use a button on the form to Open Outlook and output the report.
A previous attempt got Outlook to open and a brief screen message saying
"outputting report to ..." and then nothing. Just an open email with
nothing in the body.
After trying a few other things that didn't work, I stopped with this
attached to the button.
Private Sub SendMessage_Click()
ap_CreateOLMailItem
End Sub
I have this saved in the module.
Option Compare Database
Option Explicit
Public olkApp As Outlook.Application
Public olkNameSpace As Outlook.NameSpace
---------------------------------------------------
Sub ap_CreateOLMailItem()
Dim objMailItem As Outlook.MailItem
Dim myReport As Report
myReport.NAME = "Audit Results"
Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI")
Set objMailItem = olkApp.CreateItem(olMailItem)
With objMailItem
DoCmd.OutputTo acOutputReport, myReport, acFormatHTML,
CurrentProject.Path & "\myReport.html"
.Display
End With
Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
End Sub
"Audit Results" is the name of the report I want to insert it into the body.
I have read several posts of similar content, but as always, I want to do
things differently. I tried to piece code together for the parts that I want.
I have had numerous errors and for each I overcome, there is another.
I'd get errors here (myReport.NAME = "Audit Results") and here
(DoCmd.OutputTo acOutputReport, myReport, acFormatHTML, CurrentProject.Path &
"\myReport.html")
Any suggestions to get me on the right track?