Hey everyone, need some help here.
I have created the following code for emailing a survey (with a custom name) and then saving to a specified folder on a shared drive. There is no issue when emailing the report however I cannot get the file to save with a custom name in the shared folder.
I know it is probably something that is quite easy but I feel I am :banghead:
any help would be great
thanks in advance
____________________________________________________________
I have created the following code for emailing a survey (with a custom name) and then saving to a specified folder on a shared drive. There is no issue when emailing the report however I cannot get the file to save with a custom name in the shared folder.
I know it is probably something that is quite easy but I feel I am :banghead:
any help would be great
thanks in advance
____________________________________________________________
Code:
Private Sub EmailCallSurvey_Click()
Dim stDocName As String
Dim sAttachmentName As String
Dim myPath As String
Dim OutputTo As String
Dim Name As Variant
Dim emailto As String
myPath = "shared drive\sAttachmentName" 'Shared drive folder where all Survey's are stored
stDocName = "Rpt_call_survey_email" 'Name of the Access report Object to send
sAttachmentName = Agent & " " & "#" & [Survey#] & " " & SurveyDate 'Name to be used for the attachment in the e-mail
DoCmd.OpenReport stDocName, acViewPreview, , , acHidden
Reports(stDocName).Caption = sAttachmentName
Name = EmpName
emailto = SpvEmail
SurveyDate = SurveyDate
stDocName = "Rpt_call_survey_email"
DoCmd.SendObject acReport, stDocName, acFormatPDF, emailto, , , "Call Scorecard for" & " " & Name & " " & SurveyDate 'Subject line of email
DoCmd.OutputTo acOutputReport, sAttachmentName, acFormatPDF, , , acHidden
DoCmd.Close acReport, sAttachmentName
exit_EmailCallSurvey_Click:
Exit Sub
Err_EmailCallSurvey_click:
MsgBox Err.Description
Resume exit_EmailCallSurvey_Click
End Sub
Last edited by a moderator: