dipitiduda2
Technical User
Hello,
I recently found coding on your site that saves a MS Access file to .pdf and then emails it using MS Outlook (see faq703-2533). I have attempted to run my code and keep receiving this MsgBox error "User-defined type not defined" at line:
Dim appOutLook As Outlook.Application
See my coding below for the CLICK event. I'm just learning vb 6.0 and am unsure how to fix this problem. I may have other coding problems with this CLICK event....haven't gotten that far yet. Any help is greatly appreciated. I'm running Office XP with Windows 2000/NT 5.0 environment. Thanks!
Private Sub cmdPreviewRpt_Click()
On Error GoTo Err_cmdPreviewRpt_Click
Dim stDocName As String
Dim Name As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application"
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Name = InputBox("Enter the name for the PDF file:", "PDF"
Call SaveReportAsPDF("rpt_ExpenseRpt", "C:\work\" & Name & ".pdf"
With MailOutLook
.To = "Forms!frmOrder!PEmail"
.Subject = "mail subject"
.HTMLBody = "a HTML Body if needed"
.Attachments.Add "C:\Work\" & Name & ".pdf", olByValue, 1, "" & Name & ".pdf"
.Display
End With
stDocName = "rpt_ExpenseRpt"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdPreviewRpt_Click:
Exit Sub
Err_cmdPreviewRpt_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewRpt_Click
End Sub
I recently found coding on your site that saves a MS Access file to .pdf and then emails it using MS Outlook (see faq703-2533). I have attempted to run my code and keep receiving this MsgBox error "User-defined type not defined" at line:
Dim appOutLook As Outlook.Application
See my coding below for the CLICK event. I'm just learning vb 6.0 and am unsure how to fix this problem. I may have other coding problems with this CLICK event....haven't gotten that far yet. Any help is greatly appreciated. I'm running Office XP with Windows 2000/NT 5.0 environment. Thanks!
Private Sub cmdPreviewRpt_Click()
On Error GoTo Err_cmdPreviewRpt_Click
Dim stDocName As String
Dim Name As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application"
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Name = InputBox("Enter the name for the PDF file:", "PDF"
Call SaveReportAsPDF("rpt_ExpenseRpt", "C:\work\" & Name & ".pdf"
With MailOutLook
.To = "Forms!frmOrder!PEmail"
.Subject = "mail subject"
.HTMLBody = "a HTML Body if needed"
.Attachments.Add "C:\Work\" & Name & ".pdf", olByValue, 1, "" & Name & ".pdf"
.Display
End With
stDocName = "rpt_ExpenseRpt"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdPreviewRpt_Click:
Exit Sub
Err_cmdPreviewRpt_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewRpt_Click
End Sub