Hi all,
First post here, I'm learning how to use VBA. I have currently got a code that allows me to click a button and the form will be emailed to an inbox. What I'd like to add is to be able to add any supporting attachments before sending so it comes on the mail. I've read on a getFile code but not sure how to add this in to the below, appreciate any help!
First post here, I'm learning how to use VBA. I have currently got a code that allows me to click a button and the form will be emailed to an inbox. What I'd like to add is to be able to add any supporting attachments before sending so it comes on the mail. I've read on a getFile code but not sure how to add this in to the below, appreciate any help!
VBA Code:
Private Sub CommandButton1_Click()
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sendrng = Worksheets("Sheet1").Range("B2:F25")
Set AWorksheet = ActiveSheet
With Sendrng
.Parent.Select
Set rng = ActiveCell
.Select
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
With .Item
.To = ""
.CC = ""
.BCC = ""
.Subject = Worksheets("Sheet1").Range("C1")
.Send
End With
End With
rng.Select
End With
AWorksheet.Select
Sheet1.Activate
Range("c2:c3").ClearContents
Range("e2:e3").ClearContents
Range("c5") = ""
Range("B8:b10").ClearContents
Range("c8:c10").ClearContents
Range("d8:d10").ClearContents
Range("e8:e10").ClearContents
Range("f8:f10").ClearContents
Range("g8:g10").ClearContents
Range("b13") = ""
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
MsgBox "Manaul RV form has been submitted to the RV inbox", , "Submitted"
Application.DisplayAlerts = False
End Sub