Make 2 independent Subs use shared Data Values

Status
Not open for further replies.
M

mrsadmin

Hi team,

Just a quick question. Can I make 2 independent subs share, or call data values from a singular source.

example:

I have 6 subs currently that run off very similar data (sending mail to the helpdesk).

They are sent in groups of 2: 1 to the Helpdesk and 1 to the source of the original email notifying them that we have received it and sent it onwards (these are normally by 3rd party outlets).

Can I have:

Sub DistA Fwd

Sub DistA Reply

Use data (email, subject, to & from etc) from Sub DistA Core

Or something similar?

For the most part DistA values are the same for Fwd & Reply so there is a lot of duplicate code.

Cheers.

Code:
Sub DistA Fwd() 
 
'this is the basics, there is a lot more in common 
 
'-----     -----     -----     Setting Variables     -----     -----     -----'Set variable email addresses 
 
sup = "support@ domain"              'support system 
 
admin = "admin@ domain"          'future correspondence 
 
'-----     -----     -----     Getting data from original item     -----     -----     --- 
received = objitem.CC                                        'address which received original email 
 
dist = "distA"                                                     'Distributor short code 
 
distemail = objitem.SenderEmailAddress                 'distributors originating email 
 
custmail = objitem.To                                        'customers address from originating email "to" 
 
origemaildate = objitem.ReceivedTime 
 
End Sub 
 
Sub DistA Reply 
 
'repeat data 
 
'enter alternative message 
 
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Yes, if you declare them outside of the sub, at the top of the page. if you declare them constants the variable can't be changed

public const sup = "support@ domain"

public const admin = "admin@ domain"

How to: Declare A Constant (Visual Basic)

If you are using a variable and want to share it between macros, dim it at the top of the page.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Yes, if you declare them outside of the sub, at the top of the page. if you declare them constants the variable can't be changed




public const sup = "support@ domain"


public const admin = "admin@ domain"




How to: Declare A Constant (Visual Basic)




If you are using a variable and want to share it between macros, dim it at the top of the page.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P How many subs can run in one outlook VBA script Using Outlook 5
S Copy Tasks/Reminders from Shared Mailbox to Personal Tasks/Reminders Outlook VBA and Custom Forms 0
peterbata Shared Tasks Outlook for Mac Using Outlook 3
Fozzie Bear Shared Public Folders Access and Use Exchange Server Administration 0
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 3
J O365 - Adding Shared Google Calendar ICS link issue in O365 Using Outlook 0
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
N Having Shared Calendar shift to Current day Using Outlook 0
R Assign Categories "Round Robin" style but in a shared mailbox but on specific emails only Outlook VBA and Custom Forms 8
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
P Auto assign shared mailbox Outlook VBA and Custom Forms 1
C Pull Outlook shared calendars items from Excel Outlook VBA and Custom Forms 4
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
R VBA for copying sent email to current folder under a shared mailbox Outlook VBA and Custom Forms 17
M Outlook 365 Searching all shared calendars Outlook VBA and Custom Forms 4
S newly added shared mailboxes downloading 500GB data a day Exchange Server Administration 1
R auto send email when meeting closes from a shared calendar only Outlook VBA and Custom Forms 2
A New email notification on shared mailbox Outlook VBA and Custom Forms 0
N Shared mailbox in cached mode Using Outlook 0
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
D Shared Mailbox question Exchange Server Administration 1
S Import contacts to a shared mailbox Outlook VBA and Custom Forms 2
R Copy Outlook Public Folders to a File Server Shared Folder Using Outlook 0
D Delete Emails from Senders in Shared Mailbox Outlook VBA and Custom Forms 1
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
J Updating existing entry on shared calendar wants to send update from delegate Using Outlook 0
C Changed By field not displaying individual user's name in O365 Shared Mailbox Using Outlook 9
G Unable to dismiss reminders from share point list calendar shared in Outlook Using Outlook 2
M how to speed up search of shared contacts Using Outlook 0
M Using conditional formatting on a shared calendar with categories Using Outlook 6
S Recovering permanently deleted folder from shared mailbox Using Outlook 1
S How to extract mail items from multiple folders and shared mailboxes? Outlook VBA and Custom Forms 0
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
C Outlook Shared Calendar Using Outlook 1
N Does a Shared Folder Policy override a Digital Signature Setting for macros? Outlook VBA and Custom Forms 6
K Other Shared Calendar on Outlook cannot change items Using Outlook.com accounts in Outlook 7
I Application_NewMailEx for shared mailbox Outlook VBA and Custom Forms 1
P Macro to attach a file in a shared Outlook draft folder Outlook VBA and Custom Forms 2
Diane Poremsky Shared Mailboxes and the Default 'Send From' Account New Slipstick.com Articles 0
Mark White vba to create a shared mailbox folder Outlook VBA and Custom Forms 3
M Linking Excel Cell to Shared Contacts Outlook VBA and Custom Forms 7
Jeanne Goodman Create Printout from Multiple Shared Calendars Outlook VBA and Custom Forms 8
Diane Poremsky Shared Calendar Can't Be Deleted New Slipstick.com Articles 0
R Outlook 2007 - Shared Accounts and Resources without Exchange Server Using Outlook 0
D VBA macro printing attachments in shared mailbox Outlook VBA and Custom Forms 1
oliv- Treat once an email with the ItemAdd event in a shared mailbox Outlook VBA and Custom Forms 2
K VBA to measure response time for each emails in a shared mailbox Outlook VBA and Custom Forms 11
A Get shared calendar name or id in custom appointment form Using Outlook 0
S Shared Mailbox Alert Outlook VBA and Custom Forms 7

Similar threads

Top