Back again for more help!
As per title. Current code looks like this -
The bit I want to change is this -
I've created the UserForm -
But I don't know how to actually incorporate it into my current code. Can anyone help?
As per title. Current code looks like this -
VBA Code:
Sub XXXX()
'Set variables
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim combody As String
Dim upname As String
Dim EmptyRow As Range
Dim wsLOG As Worksheet: Set wsLOG = Worksheets("LOG")
'Set up comments InputBox
combody = InputBox("Please enter any comments", "Comments")
'Set up initials InputBox
upname = InputBox("Please enter your name", "Updated By")
'Set up Outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Create Mail in Outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Hello," & vbNewLine & vbNewLine & _
"This is a test" & vbNewLine & vbNewLine & _
"**********THIS EMAIL HAS BEEN AUTOMATICALLY GENERATED, PLEASE DO NOT RESPOND**********"
On Error Resume Next
With OutMail
.To = "XXXX"
.CC = ""
.BCC = ""
.Subject = "TEST"
.Body = strbody & vbNewLine & vbNewLine & "COMMENTS - " & combody & vbNewLine & vbNewLine & "UPDATE BY - " & upname
'You can add a file like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use.Display
End With
On Error GoTo 0
'Write details to log
Set EmptyRow = wsLOG.Range("A" & wsLOG.Cells(Rows.Count, "A").End(xlUp).Row + 1).Resize(1, 4)
EmptyRow.Cells(1).Value2 = combody: EmptyRow.Cells(2).Value2 = Date: EmptyRow.Cells(3).Value2 = Time: EmptyRow.Cells(4).Value2 = upname
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox ActiveCell.Value & vbNewLine & _
"UPDATE SENT"
End Sub
The bit I want to change is this -
I've created the UserForm -
But I don't know how to actually incorporate it into my current code. Can anyone help?