Hello All!
I have a form where users can select multiple options for creating an email.
I help manage an annual Day Camp and I'm updating some of the code during the "off season".
One of my responsibilities is to keep the unit leaders up-to-date with roster changes.
I have code that lets me choose whether or not to include a table of the unit members in the body of the email; whether or not to attach a pdf of the roster; and whether or not the pdf roster should be the roster that's already been run or if a new roster should be run.
Each combination of options is used in a number of "Select Case" statements.
I'd like to streamline the code so I don't have to make changes in as many places.
Is there a way to switch between methods or turn them on and off?
For example, if the pdf file should be attached, the snippet of code would be:
**Note: this code is a very simplified version of what I have; in reality, there is code before this selecting the correct email; determining the file to use; and building the body of the email.
**There are also several other methods included in the With statements.
**The code that I have works with no issues, I'm just trying to reduce things
If I don't want to include the pdf file, I have a copy the entire code with the attachments method commented out:Code:With EmailItem .To = UL_email .Subject = SubjText .HTMLBody = MsgText .Attachments.Add FileName .Display End With
Is there any VBA code add or remove the ".Attachements.Add FileName" bit?Code:With EmailItem .To = UL_email .Subject = SubjText .HTMLBody = MsgText '.Attachments.Add FileName .Display End With
That way, if something in the With statement, I won't need to change it several places (and missing one or two and screwing everything up!!)
Edited to add:
And, if there is a way to do this, where in the overall code should I put it??
Thank You!
Susie
Girl Scout Volunteer
Kansas