Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default populating the recipient address in outlook

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default populating the recipient address in outlook

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default populating the recipient address in outlook

The code is breaking on the Me.Controls line
Do I need to reference the actual form name in the code?

"Jacob Skaria" wrote:

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default populating the recipient address in outlook

I tried this from a commandbutton click and hence used Me.Controls . You can
refer the form name instead like UserForm1.Controls

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

The code is breaking on the Me.Controls line
Do I need to reference the actual form name in the code?

"Jacob Skaria" wrote:

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default populating the recipient address in outlook

Jacob,

Thank you, its working great now

Tom

"Jacob Skaria" wrote:

I tried this from a commandbutton click and hence used Me.Controls . You can
refer the form name instead like UserForm1.Controls

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

The code is breaking on the Me.Controls line
Do I need to reference the actual form name in the code?

"Jacob Skaria" wrote:

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default populating the recipient address in outlook

I have other checkboxes on the form that are not email addresses. How do i
differentiate them? Should I change those to radio buttons?

"Jacob Skaria" wrote:

I tried this from a commandbutton click and hence used Me.Controls . You can
refer the form name instead like UserForm1.Controls

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

The code is breaking on the Me.Controls line
Do I need to reference the actual form name in the code?

"Jacob Skaria" wrote:

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default populating the recipient address in outlook

Added one more check to check whether the caption is a mail id

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
If Instr(Ctrl.Caption,"@") 0 Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

I have other checkboxes on the form that are not email addresses. How do i
differentiate them? Should I change those to radio buttons?

"Jacob Skaria" wrote:

I tried this from a commandbutton click and hence used Me.Controls . You can
refer the form name instead like UserForm1.Controls

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

The code is breaking on the Me.Controls line
Do I need to reference the actual form name in the code?

"Jacob Skaria" wrote:

Hi Thomas

Try this code. No matter how many checkboxes are there the loop collects all
receipients which are checked to a string variable

Dim Ctrl As MSForms.Control
Dim strReceipients as String
For Each Ctrl In Me.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl.Object.Value = True Then
strReceipients = strReceipients & ";" & Ctrl.Caption
End If
End If
Next
MsgBox Mid(strReceipients, 2)

If this post helps click Yes
---------------
Jacob Skaria


"thomas donino" wrote:

Hello,
I have a form with 4 checkboxes (night add more) that have email addresses.
I cant sort out how to determine which ones are checked to write them into
the recipient area. My thought was to set a variable, the say if #1 is
checked write it to the variable and if the second is checked add it to the
variable or if nothing check # 3 etc etc etc. Am I on the right course? Is
there a more efficient way to code this?

Thank you

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
outlook task recipient Atishoo Excel Programming 7 June 5th 09 03:51 PM
Pull Recipient from Outlook Address book BigPig Excel Programming 9 May 26th 09 06:34 AM
how to make OUTLOOK EXPRESS mail recipient in excel mihir shah Excel Discussion (Misc queries) 1 November 6th 05 02:10 PM
How do I import Office address book to Outlook Express address bo. snnorp Excel Discussion (Misc queries) 2 February 22nd 05 11:47 AM
How to insert an address from Outlook 2003 address book ? Dubois Excel Programming 0 September 27th 04 09:26 AM


All times are GMT +1. The time now is 11:43 PM.

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"