We run the following VBA code following the refresh of a document on Broadcast Agent. The idea is for Broadcast agent to attatch the saved file to an email and send it.
Private Sub Document_AfterRefresh()
'File Split
Dim MyDoc As busobj.Document
Dim MyRpt As busobj.Report
Dim MyFilterVar As DocumentVariable
Dim MyFilterChoices As Variant
Dim i, intNumChoices As Integer
Dim StrNextValue As String
Set MyDoc = Application.Documents(1)
Set MyRpt = ActiveReport
Set MyFilterVar = MyDoc.DocumentVariables("Division"
intNumChoices = UBound(MyFilterVar.Values(boUniqueValues))
MyFilterChoices = MyFilterVar.Values(boUniqueValues)
'Open and Create Email
Dim Session As Object
Dim DB As Object
Set Session = CreateObject("Notes.Notessession"
Set DB = Session.GETDATABASE("", ""
Call DB.OPENMAIL
Set Doc = DB.CREATEDOCUMENT
Doc.Form = "Main Topic"
Doc.Subject = "Other Force Crimes"
Set rtitem = Doc.CREATERICHTEXTITEM("Body"
'Loop to Create files and attatch to email
For i = 1 To intNumChoices
StrNextValue = MyFilterChoices(i)
MyRpt.AddComplexFilter MyFilterVar, "=<Division>=" & """" & StrNextValue & """"
MyRpt.ForceCompute
MyRpt.ExportAsRtf ("C:\temp\NPC" & StrNextValue & ".rtf"
Set Object = rtitem.EMBEDOBJECT(1454, "", "C:\temp\NPC" & StrNextValue & ".rtf", ""
Next i
'Send Email
Call Doc.Send(True, "EMAIL ADDRESS"
DB.Close
Session.Close
Set DB = Nothing
Set Session = Nothing
End Sub
The following message comes up in the console: -
Error: "(303) Error with no ErrorHandler with BreAKOnVBAError=False"
Any ideas as to what might be wrong? The VBA runs fine when done from a desktop.
Private Sub Document_AfterRefresh()
'File Split
Dim MyDoc As busobj.Document
Dim MyRpt As busobj.Report
Dim MyFilterVar As DocumentVariable
Dim MyFilterChoices As Variant
Dim i, intNumChoices As Integer
Dim StrNextValue As String
Set MyDoc = Application.Documents(1)
Set MyRpt = ActiveReport
Set MyFilterVar = MyDoc.DocumentVariables("Division"
intNumChoices = UBound(MyFilterVar.Values(boUniqueValues))
MyFilterChoices = MyFilterVar.Values(boUniqueValues)
'Open and Create Email
Dim Session As Object
Dim DB As Object
Set Session = CreateObject("Notes.Notessession"
Set DB = Session.GETDATABASE("", ""
Call DB.OPENMAIL
Set Doc = DB.CREATEDOCUMENT
Doc.Form = "Main Topic"
Doc.Subject = "Other Force Crimes"
Set rtitem = Doc.CREATERICHTEXTITEM("Body"
'Loop to Create files and attatch to email
For i = 1 To intNumChoices
StrNextValue = MyFilterChoices(i)
MyRpt.AddComplexFilter MyFilterVar, "=<Division>=" & """" & StrNextValue & """"
MyRpt.ForceCompute
MyRpt.ExportAsRtf ("C:\temp\NPC" & StrNextValue & ".rtf"
Set Object = rtitem.EMBEDOBJECT(1454, "", "C:\temp\NPC" & StrNextValue & ".rtf", ""
Next i
'Send Email
Call Doc.Send(True, "EMAIL ADDRESS"
DB.Close
Session.Close
Set DB = Nothing
Set Session = Nothing
End Sub
The following message comes up in the console: -
Error: "(303) Error with no ErrorHandler with BreAKOnVBAError=False"
Any ideas as to what might be wrong? The VBA runs fine when done from a desktop.