W
Wayne-I-M
Hi all
I have a public function that is called from a small (very simple) module.
The code fails after the 1st var instance on the send object. That is it
will send the first report then copy the second but then will not send it if
the (2nd) report is formated RTF.
I get an error message
2046 the Send Object method is not available now.
This is not an Outlook problem as the send object works fine if I change the
format to SNP – at the moment it is RTF. So the problem must be in the
access vba.
I have spent 2 days on this (mad 2 lines of code) trying everything I can
think of to find out why this would be – the keys on my keyboard that spell
google are now worn out
Has anyone an idea why you can send multiple instances of an SNP file but it
fails when sending an RTF
Many thanks for any help or hints you may have. I can work out most thing
so if you just have any pointers (going in the right direction) that would
help also
________________________________________
This is the basic code
Public Sub SendEmailAll_Click()
Dim varItem As Variant
For Each varItem In Me.CmbClientList.ItemsSelected
Me.txtContact1stName = CmbClientList.Column(6, varItem)
Me.txtClientID = CmbClientList.Column(0, varItem)
'THIS WORKS FINE'
DoCmd.CopyObject , ETC, ETC.
' THIS WORKS FINE '
Me.txtClientID = Me.CmbClientList.Column(0, varItem)
' THIS WORKS FINE '
DoCmd.OpenReport ETC ETC
'THIS DOES NOT WORK AFTER THE 1ST RECORD'
DoCmd.SendObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem), "RichTextFormat(*.rtf)", "E
MAIL ADDRESS DELETED FOR THIS POST ", , "", "Bookings Summery", "MESSAGE TEXT
HERE", False, ""
' THIS WORKS FINE '
DoCmd.Close acReport ETC ETC
'THIS WORKS FINE '
DoCmd.DeleteObject acReport, ETC ETC
' THIS WORKS FINE '
Next varItem
' THIS WORKS FINE '
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE")
' THIS WORKS FINE '
DoCmd.Quit
End Sub
________________________________________
This is the full code - you may spot an error that I've missed ??
Public Sub SendEmailAll_Click()
Dim varItem As Variant
For Each varItem In Me.CmbClientList.ItemsSelected
Me.txtContact1stName = CmbClientList.Column(6, varItem)
Me.txtClientID = CmbClientList.Column(0, varItem)
'Copy charity and rename it'
DoCmd.CopyObject , "Booking Details" & " " & Format(Date, "short date") & "
" & CmbClientList.Column(1, varItem), acReport, "repCharityReport"
'set value to filter the report'
Me.txtClientID = Me.CmbClientList.Column(0, varItem)
'open the new report'
DoCmd.OpenReport "Booking Details" & " " & Format(Date, "short date") & " "
& CmbClientList.Column(1, varItem), acViewPreview, "",
"[DCCharityID]=[Forms]![frmReportSelector]![text34]", acHidden
'send the new report to the client'
DoCmd.SendObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem), "RichTextFormat(*.rtf)", "E
MAIL ADDRESS DELETED FOR THIS POST", , "", "Bookings Summery", "New format
automated report" & Chr(13) + Chr(10) & String(70, "_") _
& Chr(13) + Chr(10) & Chr(13) + Chr(10) & "Hi " & [txtContact1stName] &
Chr(13) + Chr(10) & Chr(13) + Chr(10) & "I have attached a report showing
details of your current bookings." & Chr(13) + Chr(10) & Chr(13) + Chr(10) &
"The report gives details up to " & Format(Now, "dd mmmm yyyy hh:nn AM/PM") &
"." & Chr(13) + Chr(10) & Chr(13) + Chr(10) & "Please note this report is
fully automated; please ensure your IT dept. adds our IP address ( IP ADDRESS
REMOVED FOR THIS POST ) and E Mail address to your white list." & Chr(13) +
Chr(10) & Chr(13) + Chr(10) & "If there are any problems with this report
please contact me." & Chr(13) + Chr(10) & Chr(13) + Chr(10) & "SOME NAME
HERE" & Chr(13) + Chr(10) & "TELEPHONE NUMBER REMOVED FOR THIS POST", False,
""
'close the new report'
DoCmd.Close acReport, "Booking Details" & " " & Format(Date, "short date") &
" " & CmbClientList.Column(1, varItem)
'Deletes the new report - but leave the original template in place'
DoCmd.DeleteObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem)
'go to next item on the list and do it again'
Next varItem
'Open Outlook so the mails will send - outlook has a close action after the
send'
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE")
'close access'
DoCmd.Quit
End Sub
I have a public function that is called from a small (very simple) module.
The code fails after the 1st var instance on the send object. That is it
will send the first report then copy the second but then will not send it if
the (2nd) report is formated RTF.
I get an error message
2046 the Send Object method is not available now.
This is not an Outlook problem as the send object works fine if I change the
format to SNP – at the moment it is RTF. So the problem must be in the
access vba.
I have spent 2 days on this (mad 2 lines of code) trying everything I can
think of to find out why this would be – the keys on my keyboard that spell
google are now worn out
Has anyone an idea why you can send multiple instances of an SNP file but it
fails when sending an RTF
Many thanks for any help or hints you may have. I can work out most thing
so if you just have any pointers (going in the right direction) that would
help also
________________________________________
This is the basic code
Public Sub SendEmailAll_Click()
Dim varItem As Variant
For Each varItem In Me.CmbClientList.ItemsSelected
Me.txtContact1stName = CmbClientList.Column(6, varItem)
Me.txtClientID = CmbClientList.Column(0, varItem)
'THIS WORKS FINE'
DoCmd.CopyObject , ETC, ETC.
' THIS WORKS FINE '
Me.txtClientID = Me.CmbClientList.Column(0, varItem)
' THIS WORKS FINE '
DoCmd.OpenReport ETC ETC
'THIS DOES NOT WORK AFTER THE 1ST RECORD'
DoCmd.SendObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem), "RichTextFormat(*.rtf)", "E
MAIL ADDRESS DELETED FOR THIS POST ", , "", "Bookings Summery", "MESSAGE TEXT
HERE", False, ""
' THIS WORKS FINE '
DoCmd.Close acReport ETC ETC
'THIS WORKS FINE '
DoCmd.DeleteObject acReport, ETC ETC
' THIS WORKS FINE '
Next varItem
' THIS WORKS FINE '
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE")
' THIS WORKS FINE '
DoCmd.Quit
End Sub
________________________________________
This is the full code - you may spot an error that I've missed ??
Public Sub SendEmailAll_Click()
Dim varItem As Variant
For Each varItem In Me.CmbClientList.ItemsSelected
Me.txtContact1stName = CmbClientList.Column(6, varItem)
Me.txtClientID = CmbClientList.Column(0, varItem)
'Copy charity and rename it'
DoCmd.CopyObject , "Booking Details" & " " & Format(Date, "short date") & "
" & CmbClientList.Column(1, varItem), acReport, "repCharityReport"
'set value to filter the report'
Me.txtClientID = Me.CmbClientList.Column(0, varItem)
'open the new report'
DoCmd.OpenReport "Booking Details" & " " & Format(Date, "short date") & " "
& CmbClientList.Column(1, varItem), acViewPreview, "",
"[DCCharityID]=[Forms]![frmReportSelector]![text34]", acHidden
'send the new report to the client'
DoCmd.SendObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem), "RichTextFormat(*.rtf)", "E
MAIL ADDRESS DELETED FOR THIS POST", , "", "Bookings Summery", "New format
automated report" & Chr(13) + Chr(10) & String(70, "_") _
& Chr(13) + Chr(10) & Chr(13) + Chr(10) & "Hi " & [txtContact1stName] &
Chr(13) + Chr(10) & Chr(13) + Chr(10) & "I have attached a report showing
details of your current bookings." & Chr(13) + Chr(10) & Chr(13) + Chr(10) &
"The report gives details up to " & Format(Now, "dd mmmm yyyy hh:nn AM/PM") &
"." & Chr(13) + Chr(10) & Chr(13) + Chr(10) & "Please note this report is
fully automated; please ensure your IT dept. adds our IP address ( IP ADDRESS
REMOVED FOR THIS POST ) and E Mail address to your white list." & Chr(13) +
Chr(10) & Chr(13) + Chr(10) & "If there are any problems with this report
please contact me." & Chr(13) + Chr(10) & Chr(13) + Chr(10) & "SOME NAME
HERE" & Chr(13) + Chr(10) & "TELEPHONE NUMBER REMOVED FOR THIS POST", False,
""
'close the new report'
DoCmd.Close acReport, "Booking Details" & " " & Format(Date, "short date") &
" " & CmbClientList.Column(1, varItem)
'Deletes the new report - but leave the original template in place'
DoCmd.DeleteObject acReport, "Booking Details" & " " & Format(Date, "short
date") & " " & CmbClientList.Column(1, varItem)
'go to next item on the list and do it again'
Next varItem
'Open Outlook so the mails will send - outlook has a close action after the
send'
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE")
'close access'
DoCmd.Quit
End Sub