How many subs can run in one outlook VBA script

Status
Not open for further replies.
Outlook version
Outlook 2007
Email Account
IMAP
I would like to run a script (that you already helped me with) to send Email information to Trello. I would also like to send a copy of that same information to an Excel Spread Sheet which I managed to do with some slight modifications of one of your sample scripts. My question is how do I run them both on the same message as it arrives? Do I put them inside the same script and if so do I end Sub and start the second Sub?Attached is a copy of both my Modules.
 

Attachments

  • sent2Excel.pdf
    362.1 KB · Views: 750
  • sent2Trello.pdf
    278.2 KB · Views: 340

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
There's no limit, and there's a lot of ways to accomplish it. This is one:
Code:
public sub CallThisByYourRule(mail as mailitem)
   script_one mail
  script_two mail
end sub

private sub script_one(mail as mailitem)
end sub

private sub script_two(mail as mailitem)
end sub
 
Outlook version
Outlook 2007
Email Account
IMAP
There's no limit, and there's a lot of ways to accomplish it. This is one:
Code:
public sub CallThisByYourRule(mail as mailitem)
   script_one mail
  script_two mail
end sub

private sub script_one(mail as mailitem)
end sub

private sub script_two(mail as mailitem)
end sub
Nice. Thanks. I'll give it a try... Were you able to answer the two minor issues I have with my private subs?
Excel works but I need to grab the CC# at the top and haven't been able to do it inside the current pattern...
And I'm not sure how you make these apply to all emails in a folder instead of just the one that is selected.
 
Outlook version
Outlook 2007
Email Account
IMAP
At the beginning of this thread I included two scripts that I'm running. inside the documents are an issues at the top.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Assuming both scripts work individually, use the example Michael posted with 3macros. One macro is called by a rule an it calls macro1. When macro1 is finished, it goes back to the original macro and runs macro2.

You could put both together in one macro, but using two can be less confusing and allows you to run them separately, if needed.

If you need to share variables, you can do that too.

public sub CallThisByYourRule(mail as mailitem)
' run this macro first
script_one mail
' when the macro above is finished, return and run the second macro.
script_two mail
end sub
private sub script_one(mail as mailitem)
end sub
private sub script_two(mail as mailitem)
end sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J How to import many msg into different public folders in Outlook Outlook VBA and Custom Forms 7
O Same email address, same person, names in so many ways Using Outlook 4
J Moved many emails to Outlook external folder, need to delete on Gmail server Using Outlook 14
B Task Filter Not Working When I add too many criteria Using Outlook 0
T Many problems with outlook.com - will upgrade to Outlook soon Using Outlook 1
D Too many scripts? Outlook VBA and Custom Forms 1
GregS Outlook 2016 Too Many Archives Using Outlook 0
GregS Many Sent Item folders Using Outlook 3
P how to remove unwanted PST file default categories assigned to many calendar entries Using Outlook 7
L Why do i get so many drafts? Using Outlook 12
T Received many email without information Using Outlook 1
M How many days are items in Recover Deleted at Outlook.com ? Using Outlook.com accounts in Outlook 4
O Copy mails from many subfolders to 1 foldr Using Outlook 2
C too many choices for time zones! can i reduce to actual time zones only? Using Outlook 1
M warning for too many appointments on a same day in Outlook Using Outlook 1
M Charter ISP Claims Outlook Generating STMP Errors of Too Many Recipients Using Outlook 1
D Meeting Request - Too Many Recipients Using Outlook 0
Diane Poremsky "Too many files" Error Message Using Outlook 0
O W-a-a-y too many PSTs (Outlook 2003) Using Outlook 0
I Many empty Contacts folders.. cannot get rid of them Using Outlook 4
A Importing too many emails from Gmail Using Outlook 2
R Many folders Using Outlook 11
R Rules - many or few Using Outlook 10
mikecox Too many "contacts" lists Using Outlook 2
S Setup many personal calendars on outlook 2013 on new laptop- starting over Using Outlook 1
W Outlook 2010 has many inbox folders Using Outlook 5
C Many Expiration Dates in Custom Form Using Outlook 1
T Public Folder has many messages but can't be seen in Outlook Using Outlook 3
R How many seconds usually takes an email to get to an outlook account? Using Outlook 0
J Want ONE inbox MANY accounts Using Outlook 2
R Too Many Devices Using Outlook 2
C BCC - How many email address will it accomodate? Using Outlook 2
R Too many folders in Outlook 2013 Using Outlook 11
D Navigate to my calendar. Too many steps Exchange Server Administration 2
B Problem with fix for "Too Many Contact Folders" Using Outlook 3
B [outlook-users] Re: Why have I gotten to many "reminders" for birthdays that "occurred" on Jan. 1??? Using Outlook 3
M Outlook 2010 is loading many times already received emails from external acc. Using Outlook 4
C Updating many contacts at once? BCM (Business Contact Manager) 3
D How Many Exchange Accounts in Outlook? Exchange Server Administration 3
B Too many ' tasks' when checking email Using Outlook 1
G How many contacts can be imported into BCM BCM (Business Contact Manager) 1
M Make 2 independent Subs use shared Data Values Using Outlook 3
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
G Save attachment run a script rule Outlook VBA and Custom Forms 0
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
D Outlook 2013 Macros only run in VB editor, not in drop down or button Outlook VBA and Custom Forms 10
D We're sorry but outlook has run into an error Using Outlook 6
M White square in body of Outlook Messages (O2016 Version 2012 32bit Click To Run) Using Outlook 4
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1

Similar threads

Top