Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to count checkboxes and use in .Recipients.add?
I have several checkboxes with names of some of my
collegeaus on a Userform (chkPeter, chkMartin, etc). I want to used the emailadres that is associated to those checkboxes. I used the .ControlTip property of the checkbox to store the emailadres I need. Now I want to send an email to a collegeau if his checkbox is checked (chkPeter = True). From www.rondebruin.nl I already got: Private Sub Mail_Workbook_Outlook() 'This example send the last saved version of the Activeworkbook 'You must add a reference to the Microsoft outlook Library Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(olMailItem) With OutMail 'Here I need code to get usernames depending on the checkboxes that are checked: .To = " For j = 1 To CheckBoxes.Count '??HOW do I count number of checked checkboxes?? .Recipients.Add = chk(i).ControlTipText Next .CC = "" .BCC = "" .Subject = "This is the Subject line - Mail Workbook" .Body = "Hi there" '.Attachments.Add ActiveWorkbook.FullName .Attachments.Add ActiveWorkbook.Path & "\" & ActiveWorkbook.Name 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .Display '.Send 'or use End With Set OutMail = Nothing Set OutApp = Nothing End Sub How can I use a loop to : 1. check the name of the checked checkboxes; 2. read the emailaddress? Thanks in advance! Martin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to count checkboxes and use in .Recipients.add?
Hi Martin
Try this loop If the value is true add it Sub test() Dim ctl As Control For Each ctl In UserForm1.Controls If TypeOf ctl Is MSForms.CheckBox Then If ctl.Value = True Then 'add it Else 'do nothing End If End If Next End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Martin Los" wrote in message ... I have several checkboxes with names of some of my collegeaus on a Userform (chkPeter, chkMartin, etc). I want to used the emailadres that is associated to those checkboxes. I used the .ControlTip property of the checkbox to store the emailadres I need. Now I want to send an email to a collegeau if his checkbox is checked (chkPeter = True). From www.rondebruin.nl I already got: Private Sub Mail_Workbook_Outlook() 'This example send the last saved version of the Activeworkbook 'You must add a reference to the Microsoft outlook Library Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(olMailItem) With OutMail 'Here I need code to get usernames depending on the checkboxes that are checked: .To = " For j = 1 To CheckBoxes.Count '??HOW do I count number of checked checkboxes?? .Recipients.Add = chk(i).ControlTipText Next .CC = "" .BCC = "" .Subject = "This is the Subject line - Mail Workbook" .Body = "Hi there" '.Attachments.Add ActiveWorkbook.FullName .Attachments.Add ActiveWorkbook.Path & "\" & ActiveWorkbook.Name 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .Display '.Send 'or use End With Set OutMail = Nothing Set OutApp = Nothing End Sub How can I use a loop to : 1. check the name of the checked checkboxes; 2. read the emailaddress? Thanks in advance! Martin |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to count checkboxes and use in .Recipients.add?
That´s just what I needed!
Hartelijk bedankt Ron. Martin -----Original Message----- Hi Martin Try this loop If the value is true add it Sub test() Dim ctl As Control For Each ctl In UserForm1.Controls If TypeOf ctl Is MSForms.CheckBox Then If ctl.Value = True Then 'add it Else 'do nothing End If End If Next End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Martin Los" wrote in message ... I have several checkboxes with names of some of my collegeaus on a Userform (chkPeter, chkMartin, etc). I want to used the emailadres that is associated to those checkboxes. I used the .ControlTip property of the checkbox to store the emailadres I need. Now I want to send an email to a collegeau if his checkbox is checked (chkPeter = True). From www.rondebruin.nl I already got: Private Sub Mail_Workbook_Outlook() 'This example send the last saved version of the Activeworkbook 'You must add a reference to the Microsoft outlook Library Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(olMailItem) With OutMail 'Here I need code to get usernames depending on the checkboxes that are checked: .To = " For j = 1 To CheckBoxes.Count '??HOW do I count number of checked checkboxes?? .Recipients.Add = chk(i).ControlTipText Next .CC = "" .BCC = "" .Subject = "This is the Subject line - Mail Workbook" .Body = "Hi there" '.Attachments.Add ActiveWorkbook.FullName .Attachments.Add ActiveWorkbook.Path & "\" & ActiveWorkbook.Name 'You can add other files also like this '.Attachments.Add ("C:\test.txt") .Display '.Send 'or use End With Set OutMail = Nothing Set OutApp = Nothing End Sub How can I use a loop to : 1. check the name of the checked checkboxes; 2. read the emailaddress? Thanks in advance! Martin . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can I count checkboxes that have been checked? | Excel Discussion (Misc queries) | |||
Mail Merge Without Recipients - Is It Something Else? | Excel Discussion (Misc queries) | |||
Mail Recipients | Setting up and Configuration of Excel | |||
how do you count checkboxes in excel2003 | Excel Worksheet Functions | |||
code Help - Routing Recipients | Excel Programming |