Need help fixing run-time error 429....

marcorangel

New Member
Joined
Jun 25, 2014
Messages
1
Hello all,
I need your help in making this code work..
I should preface this by stating that I'm relatively new to VBA code so please don't get to technical on me....

This code utilized access tables to generage emails that get sent out, however, once it gets to the process called "run no survey distrcts" it gets stuck and it gives me a run-time error 429 saying that the ActiveX component can not create the object.

Here is the code:

Sub NonTopBoxReport()
Dim rs As DAO.Recordset
Dim olApp As Object
Dim objMail As Object

'Run non-top box district reports
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblDistrictsWithNonTopBox")
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
DoCmd.OpenReport "DailySummaryNTB", acViewPreview, , "TIER60_DIST_NM = '" & rs!TIER60_DIST_NM & "'"
DoCmd.OutputTo acOutputReport, "DailySummaryNTB", acFormatPDF, "C:\Users\u097951\Desktop\CE Daily Report\" & rs!District_Name & ".pdf", False
DoCmd.SendObject acSendReport, "DailySummaryNTB", acFormatPDF, rs!District_Manager_Email, "myemailaddress@me.com; " & rs!Market_President_Email & "; " & rs!All_MSC, , "CE Daily Summary - " & rs!District_Name, , False
DoCmd.Close acReport, "DailySummaryNTB"
rs.MoveNext
Loop
Else
End If

'Run all top box district reports
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblDistrictsWithAllTopBox")
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
DoCmd.OpenReport "DailySummaryATB", acViewPreview, , "TIER60_DIST_NM = '" & rs!TIER60_DIST_NM & "'"
DoCmd.OutputTo acOutputReport, "DailySummaryATB", acFormatPDF, "C:\Users\u097951\Desktop\CE Daily Report\" & rs!District_Name & ".pdf", False
DoCmd.SendObject acSendReport, "DailySummaryATB", acFormatPDF, rs!District_Manager_Email, "myemailaddress@me.com; " & rs!Market_President_Email & "; " & rs!All_MSC, , "CE Daily Summary - " & rs!District_Name, , False
DoCmd.Close acReport, "DailySummaryATB"
rs.MoveNext
Loop
Else
End If

'Run no survey districs process
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tblDistrictsWithNoSurveys")
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True

Set olApp = GetObject(, "Outlook.Application")
Set objMail = olApp.createitem(olMailItem)

With objMail
.BodyFormat = olFormatHTML
.To = rs!District_Manager_Email
.CC = "myemailaddress@me.com; " & rs!Market_President_Email & "; " & rs!All_MSC
.Subject = "CE Daily Summary - " & rs!District_Name & " (No Surveys)"
.HTMLBody = "No surveys to report."
.Send
End With

rs.MoveNext
Loop
Else
End If

With DoCmd
.SetWarnings False
.OpenQuery "qryLastProcessedSurveyDate"
.SetWarnings True
End With
rs.Close
DoCmd.Quit
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top