Yakillinmesmalls
New Member
- Joined
- Feb 11, 2022
- Messages
- 8
- Office Version
- 2016
- Platform
- Windows
Hi, I'm creating an Incident Management form that has two buttons. One for injuries and the other for near misses. when the injury button is clicked, a message pops up instructing the employee on next steps, once the OK button is clicked on the message box, the email pops up where the employee just has to fill out the questions in the body, open and save the attached injury report form to their desktop, fill it out and attach the completed form back to the email that is already populated with the required recipients. Problem I'm running into is that I want the sheet 2 that has the injury report form to be attached, not sheet 1 that has the two buttons. How do I achieve this?
Private Sub CommandButton1_Click()
Dim xOutlookObj As Object
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Description of Injury:" & vbNewLine & vbNewLine & _
"Type of Injury:" & vbNewLine & vbNewLine & _
"Treatment Disposition (First-Aid, ER, Urgent Care, etc.):"
On Error Resume Next
With xOutMail
.To = "ObviouslynotmyrealEmail.com"
.CC = ""
.BCC = ""
.Subject = "Injury Report (Location and Date of Injury)"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
MsgBox Prompt:="Click OK; Fill out email; Save attachment as IR-(Date of Injury) to desktop; attach completed form to email and Send"
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Private Sub CommandButton1_Click()
Dim xOutlookObj As Object
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Description of Injury:" & vbNewLine & vbNewLine & _
"Type of Injury:" & vbNewLine & vbNewLine & _
"Treatment Disposition (First-Aid, ER, Urgent Care, etc.):"
On Error Resume Next
With xOutMail
.To = "ObviouslynotmyrealEmail.com"
.CC = ""
.BCC = ""
.Subject = "Injury Report (Location and Date of Injury)"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
MsgBox Prompt:="Click OK; Fill out email; Save attachment as IR-(Date of Injury) to desktop; attach completed form to email and Send"
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub