Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I count checkboxes that have been checked? Jay Excel Discussion (Misc queries) 3 May 4th 09 05:16 PM
Mail Merge Without Recipients - Is It Something Else? Dave Excel Discussion (Misc queries) 0 September 12th 07 05:10 PM
Mail Recipients George Schneider Setting up and Configuration of Excel 3 January 4th 06 08:26 AM
how do you count checkboxes in excel2003 plhanlon Excel Worksheet Functions 1 August 23rd 05 07:05 PM
code Help - Routing Recipients Neil[_15_] Excel Programming 1 October 28th 03 08:41 PM


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"