PDA

View Full Version : Email Active workbook with updates made



Bouchard17
02-23-2021, 09:49 AM
Hi Folks, :hi:

I am new to the world of VBA and slowly understanding more about each aspect of code, however i am not quite there yet. :(

I have recently created a proforma document that captures information from an end user. Once completed the end user hits the relevant buttons and this then sends an email to their manager for review before heading off to the relevant department to action the request.
I have had feedback that the code works and sends the email (great) but the excel attachment does not include the updates that the user has applied before sending. I want to be able to send/forward the active workbook with the changes/updates that the user has applied to the relevant parties.

I have seen multiple threads that suggest the only way is to temp save the file, email and then delete this and build into vba code. Is there a way around this that you can help with with?

If not and i use the temp saving options i see on these forums will i have to select a location for the files to be saved. My reason for asking is each user has different creditinals and this form is asscessibale to over 500 users so needs to be generic.

Any help is appreciated. :yes:yes:yes


Amy



This is my current code:
Private Sub LineManagerSubmit_Click()






Dim emailApplication As Object
Dim emailItem As Object


Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)


' Now build the email.


emailItem.to = Range("C88").Value


emailItem.CC = Range("C71").Value


emailItem.Subject = "IE -" & Range("C9 ").Value & " - " & Range("F9").Value


emailItem.Body = "Hi " & Range("C89").Value & "," & vbCrLf & vbCrLf & "Please find attached details of a new error for review." & vbCrLf & vbCrLf & "Please can you review and share with the appropriate team. " & vbCrLf & vbCrLf & "If you have any questions please ask" & vbCrLf & vbCrLf & "Kind Regards" & vbCrLf & vbCrLf & Range("C7").Value


MsgBox "Your email has been sent" & vbCrLf & vbCrLf & "This file has not been saved"


' Attach current Workbook
emailItem.Attachments.Add ActiveWorkbook.FullName


' Send the Email
emailItem.Send


Set emailItem = Nothing
Set emailApplication = Nothing


End Sub

Kenneth Hobs
02-23-2021, 02:05 PM
' Attach current Workbook
ActiveWorkbook.Save
emailItem.Attachments.Add ActiveWorkbook.FullName