running multiple macros at once

holleymc

Member
Outlook version
Outlook 365 32 bit
Email Account
Office 365 Exchange
Operating system::    Windows 10
Outlook version:     Outlook 365
Email type or host:    Microsoft 365

Hello all! I have two macros that I would like to combine into a single step. Macro 1is opens a template, paste the clipboard contentes into the body of the template. Macro 2 copies the email address from the body of hte email and paste it into the To field of the email. Each of these work great individually, but I cannot even do a simple "call" for these two to work together. Any suggestions?

One other tweak I would like to make is for it to copy the Customer # and past it within the subject line of the email, but if that never happens, if I could just get the first two to work together, that would be be most appreciated!

I would greatly appreciate any suggestions!

This is the two codes:
Macro 1
Code:
Dim MyItem As Outlook.MailItem
Dim str_jpeg_file As String

Dim wdDoc As Object
Dim oRng As Object
    
    'On Error Resume Next
    Set OutApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then Set OutApp = CreateObject("Outlook.Application")
    On Error GoTo 0
    
    'Set OutMail = OutApp.CreateItem(0)
    Set MyItem = Application.CreateItemFromTemplate("C:\Users\user2\Documents\Customer Statement .msg")
    MyItem.Display
    With MyItem
        .BodyFormat = 2
       ' .To = ""
       ' .CC = ""
        '.BCC = ""
        .Subject = "Customer Statement "

SendKeys "{right}{down}^({v})", True
End With
End Sub

Macro 2
Code:
Sub ReadMsg2()
'Graham Mayor - https://www.gmayor.com - Last updated - 06 Jul 2024
Dim olMsg As MailItem
    On Error Resume Next
    Select Case Outlook.Application.ActiveWindow.Class
        Case olInspector
            Set olMsg = ActiveInspector.CurrentItem
        Case olExplorer
            Set olMsg = Application.ActiveExplorer.Selection.Item(1)
    End Select
   GetAddress olMsg
lbl_Exit:
    Set olMsg = Nothing
    Exit Sub
End Sub
Sub GetAddress(olItem As MailItem)
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim oAddr As Object
Dim hLink As Object
    With olItem
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        With oRng.Find
            Do While .Execute(findText:="Sincerely")
                Set oAddr = oRng
                Exit Do
            Loop
        End With
        If Not oAddr Is Nothing Then
            oAddr.collapse 1
            oAddr.MoveStartUntil "@", -1073741823
            Set oAddr = oAddr.Paragraphs(1).Range
            If Not oAddr Is Nothing Then
                olItem.To = oAddr.Text
                oAddr.Text = ""
            End If
        End If
    End With
lbl_Exit:
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
    Set oAddr = Nothing
    Exit Sub
End Sub
 
Similar threads
Thread starter Title Forum Replies Date
N Running multiple macros upon sending Outlook VBA and Custom Forms 6
F Running Scripts in Outlook 2021 Using Outlook 0
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
A VBscript stops running after updating form Outlook VBA and Custom Forms 1
N contact notepad 'style' getting changed after clicking and running Activities Using Outlook 2
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
S Problem running Command button code Outlook VBA and Custom Forms 2
B Automation error running VB macro code Outlook VBA and Custom Forms 8
Diane Poremsky OUTLOOK.EXE continues running after you exit Outlook Using Outlook 0
Diane Poremsky Running Outlook Macros on a Schedule Using Outlook 0
B ActiveExplorer return NULL on new Window user login and running Outlook first time Using Outlook 1
JorgeDario Template oft that contains VBScript Is not running Using Outlook 1
M Mark Complete keyboard shortcut... on a mac running Windows Bootcamp Using Outlook 0
N Outlook 2007 To-Do-List status keeps running Using Outlook 2
S The attempted operation failed ... 2nd time running code Outlook VBA and Custom Forms 3
G email returns after running macro to move emails Outlook VBA and Custom Forms 1
P Outlook Macro keeps running for the same messagage Using Outlook 2
M Accessing BCM with Excel / Running Reports BCM (Business Contact Manager) 1
G Error when running scanpst.exe Using Outlook 1
V Running scripts with Outlook 2013 Using Outlook 17
D Stopping "do you want to continue running scripts on this page" warnings Using Outlook 4
M Running macros in tasks sent out as meeting requests in invitees machine Using Outlook 4
N Rules stop running automatically Using Outlook 10
D VBA code running on Server? Shared mailbox email routing Using Outlook 3
T WAB editing: To help prevent malicious code from running.......... Using Outlook 18
M Outlook.exe 1.2Gb memory usage if running certain BCM reports BCM (Business Contact Manager) 8
M Why rules stop running automatically? Using Outlook 1
V Trouble Running Outlook 2007 and 2010 Using Outlook 4
S CSCANPST To Automate Running SCANPST.EXE Using Outlook 1
L remove a hotmail account from Outlook 2007 running on Vista home premium Using Outlook.com accounts in Outlook 1
S Outlook 2007 Running on Windows 7 hangs on send Using Outlook 7
A running code after the new inspector is visible Outlook VBA and Custom Forms 1
M Running Outlook as Scheduled task Outlook VBA and Custom Forms 1
S ActiveExplorer return NULL on new Window user login and running Outlook first time Outlook VBA and Custom Forms 19
E Word macro running from OL VBA throwing error on Word SaveAs?? Outlook VBA and Custom Forms 8
A Running Code in Side by side calendar view Outlook VBA and Custom Forms 2
G Re:Running a Macro when email arrives Outlook VBA and Custom Forms 1
D Running a Program from Custom Action Rule Outlook VBA and Custom Forms 1
O Scheduled Task Fails running Code to send Outlook Mail from Excel. Outlook VBA and Custom Forms 9
B Phantom VBA Running Outlook VBA and Custom Forms 1
G To Prevent Malicious Code from running, one or more objects in thi BCM (Business Contact Manager) 2
M If loop not running Outlook VBA and Custom Forms 1
D Troubleshooting rule/script not running Outlook VBA and Custom Forms 5
P How to use a form from a rule running on the inbox Outlook VBA and Custom Forms 1
S To help prevent malicious code from running, one or more objects in this form were not loaded. For m Outlook VBA and Custom Forms 1
Q Running the Database from a Server BCM (Business Contact Manager) 7
N Running Code before Access 2007 closes down Outlook VBA and Custom Forms 1
S Outlook rules not running automatically Using Outlook 11
ughlook Open multiple contacts in NEW Outlook? Using Outlook 3
chummy Open multiple Hyperlinks to download files Outlook VBA and Custom Forms 3

Similar threads

Back
Top