Hi to everyone!
I ve already got help here on my project (thanks Paul!) and as a total newbe I need you help once again.
Below here there is the code that generates about a 100 ratesheets for my customers. This works great.
Basically I get all the pdf ratesheets Saved with the proper name (customer name + my company name ecc.) in the folder of my choice.
Next what i wanted to do is to have those sent to each relevant recipient via E-mail.
The matter is I have no idea on how to do it, I found docmd.send object to put right after docmd.output to, but then I get the report sent basically empty and without the correct filename.
Any idea on what i can do? I ve been trying to search but i only bumped into pretty complicate stuff which i dunno where to start with...
Thanks for any suggestion you can think of!
Ciao
I ve already got help here on my project (thanks Paul!) and as a total newbe I need you help once again.
Below here there is the code that generates about a 100 ratesheets for my customers. This works great.
Basically I get all the pdf ratesheets Saved with the proper name (customer name + my company name ecc.) in the folder of my choice.
Next what i wanted to do is to have those sent to each relevant recipient via E-mail.
The matter is I have no idea on how to do it, I found docmd.send object to put right after docmd.output to, but then I get the report sent basically empty and without the correct filename.
Any idea on what i can do? I ve been trying to search but i only bumped into pretty complicate stuff which i dunno where to start with...
Code:
Private Sub Comando1_Click()
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rs As New ADODB.Recordset
rs.activeconnection = cnn1
rs.Open "[soloragsoc]"
Dim ragsoc As String
Dim pafi As String
Dim file As String
Dim path As String
Dim db As Database
Dim ingragsoc As String
Dim repName As String
repName = "newreport"
ragsoc = "[Q_Retrieve nolo export]![ragione sociale]"
pafi = path & file
If Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
ingragsoc = rs.Fields(0)
path = "C:\Users\diego.macaluso\Desktop\EXEPE"
file = "\Listino Tetris Consolidation export Maggio 2016" & " " & ingragsoc & ".pdf"
Dim fulpafi As String
fulpafi = path & file
'from now on it generates the ratesheet file based on customer name in the recordset
DoCmd.OpenReport repName, acViewPreview, , "[QQ_Retrieve nolo export]![ragione sociale] ='" & ingragsoc & "'"
DoCmd.OutputTo acOutputReport, , acFormatPDF, fulpafi
DoCmd.Close acReport, repName
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Thanks for any suggestion you can think of!
Ciao