I have Excel generate email through a macro. Added a check box on the spreadsheet and trying to make it so that when checked email is sent, if unchecked email displays.
Getting Run-time error '424': Object required on line - If CheckBox5.Value = True Then - in below bit of code
This example shows where to include the code in your existing macro. The only part that you are concerned with is the IF CHECKBOX1 portion. In this scenario I used an ACTIVEX checkbox on the sheet (not the UserForm Checkbox control).Code
- 'Set mail attributes (uncomment lines to enter attributes)
- ' In this example, only the attachment is being added to the mail message
- With oMail
- .To = toList
- .Subject = "Subject"
- .body = "Kindly find attached the deadline report." & vbCrLf & vbCrLf & _
- "Thanks and regards" & vbCrLf & vbCrLf & _
- .Attachments.Add sTemporaryPathAndFileName
- [B][COLOR=#FF0000] If Sheet1.CheckBox1.Value = True Then
- End If[/COLOR][/B]
- End With
Compile error: Method or data member not found - while highlighting ".CheckBox5" portion - in my case it is #5
I replaced existing check box with an ActiveX one and it worked. Thanks!
You are welcome.