Hello my friends!
In my database (in a server with the appropriate user control, (single database file, not splitted), i got a sub which exports a report as a pdf and then creates an email with the report and another excel file (total 2 attachements).
My problem is that in my computer (win 10, office 2013) it's working fine.
When i run the database on another computer (win 10, office 2016 without access, we use access environment 2013), when i run the sub i got the error 2501, path doesn't exist. Looking in the folder, the report has been created but then i got the error.
Both users have the same access in the database folder/subfolders.
Below is the code:
Private Sub Command75_Click()
On Error GoTo Err_Command75_Click
Dim MailRecipientTemp, MailSubject, Respo As String
Dim MailRecipient, ccResipient As String
Dim CustomerT, TypeT, CustomerD, TypeD As String
Dim stDocName As String
Dim objOutlook As Object
Dim objEmail As Object
Dim todayDate, filename, filename1 As String
Dim strBody As String
Dim strEmail, strEmailCC As String
Dim strSubject As String
Dim strPathAttach, strPathAttach1 As String
Const olMailItem As Integer = 0
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(olMailItem)
stDocName = "RespoIncomeSampleDate"
todayDate = Format(Date, "DDMMYYYY")
filename = "c:\temp\Customer Samples\PDF" & "" & stDocName & "_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, stDocName, acFormatPDF, filename, False
filename1 = "c:\temp\Customer Samples\SampleAnalysisRequest.xlsx"
MailRecipientTemp = Me.[Responsible person]
Select Case MailRecipientTemp
'Select users for mail
End Select
MailSubject = "Report"
strEmail = MailRecipient
strSubject = MailSubject
strBody = "Dear " & Respo & vbCrLf & vbCrLf & "Attached you may find the report for the new sample(s), along with the 'sample analysis request form', which you are kindly requested to complete and return it back to me." & vbCrLf & "Best Regards,"
strPathAttach = filename
strPathAttach1 = filename1
objEmail.To = strEmail
objEmail.cc = ccResipient
objEmail.Subject = strSubject
objEmail.Body = strBody
With objEmail.Attachments
'use parenthisis around the path
.Add (strPathAttach)
.Add (strPathAttach1)
End With
objEmail.Display
Set objOutlook = Nothing
Set objMailItem = Nothing
Exit_Command75_Click:
Set objOutlook = Nothing
Exit Sub
Err_Command75_Click:
MsgBox Err & ": " & Err.Description
Resume Exit_Command75_Click
End Sub
Any ideas?
Thanks!!!!!!
In my database (in a server with the appropriate user control, (single database file, not splitted), i got a sub which exports a report as a pdf and then creates an email with the report and another excel file (total 2 attachements).
My problem is that in my computer (win 10, office 2013) it's working fine.
When i run the database on another computer (win 10, office 2016 without access, we use access environment 2013), when i run the sub i got the error 2501, path doesn't exist. Looking in the folder, the report has been created but then i got the error.
Both users have the same access in the database folder/subfolders.
Below is the code:
Private Sub Command75_Click()
On Error GoTo Err_Command75_Click
Dim MailRecipientTemp, MailSubject, Respo As String
Dim MailRecipient, ccResipient As String
Dim CustomerT, TypeT, CustomerD, TypeD As String
Dim stDocName As String
Dim objOutlook As Object
Dim objEmail As Object
Dim todayDate, filename, filename1 As String
Dim strBody As String
Dim strEmail, strEmailCC As String
Dim strSubject As String
Dim strPathAttach, strPathAttach1 As String
Const olMailItem As Integer = 0
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(olMailItem)
stDocName = "RespoIncomeSampleDate"
todayDate = Format(Date, "DDMMYYYY")
filename = "c:\temp\Customer Samples\PDF" & "" & stDocName & "_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, stDocName, acFormatPDF, filename, False
filename1 = "c:\temp\Customer Samples\SampleAnalysisRequest.xlsx"
MailRecipientTemp = Me.[Responsible person]
Select Case MailRecipientTemp
'Select users for mail
End Select
MailSubject = "Report"
strEmail = MailRecipient
strSubject = MailSubject
strBody = "Dear " & Respo & vbCrLf & vbCrLf & "Attached you may find the report for the new sample(s), along with the 'sample analysis request form', which you are kindly requested to complete and return it back to me." & vbCrLf & "Best Regards,"
strPathAttach = filename
strPathAttach1 = filename1
objEmail.To = strEmail
objEmail.cc = ccResipient
objEmail.Subject = strSubject
objEmail.Body = strBody
With objEmail.Attachments
'use parenthisis around the path
.Add (strPathAttach)
.Add (strPathAttach1)
End With
objEmail.Display
Set objOutlook = Nothing
Set objMailItem = Nothing
Exit_Command75_Click:
Set objOutlook = Nothing
Exit Sub
Err_Command75_Click:
MsgBox Err & ": " & Err.Description
Resume Exit_Command75_Click
End Sub
Any ideas?
Thanks!!!!!!