Results 1 to 8 of 8

Using Outlook to run a script

Threaded View

  1. #1
    Registered User
    Join Date
    05-11-2015
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    28

    Angry Using Outlook to run a script

    Hi guys,

    I wrote a VBA on outlook which basically saves an attachment into a folder and then runs a vba code in another excel file that is saved in that folder also. However, it only runs the first vba in the second excel file. For simplicity, i have two codes in the second excel file, first is output Test in cell and then second code is create a new excel workbook and save it in the folder also.

    here is the outlook code:
    Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    saveFolder = "C:\Users\KARMAO2\Desktop"
         For Each objAtt In itm.Attachments
             objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
            Set objAtt = Nothing
         Next
         Call Application_Startup
    End Sub
    
    Private Sub Application_Startup()
    Dim ExApp As Excel.Application
    Dim ExWbk As Workbook
    Set ExApp = New Excel.Application
    Set ExWbk = ExApp.Workbooks.Open("C:\Users\KARMAO2\Desktop\TESTING MACRO.xlsm")
    ExApp.Visible = True
    ExWbk.Application.Run "Module1.Test_Open()"
    ExWbk.Application.Run "Module1.AddNewWorkbook2()"
    ExWbk.Close SaveChanges:=True
    End Sub


    Here is the code for second excel file
    Sub Test_Open()
    
    Range("A1").Value = "Testing"
    
    End Sub
    
    
    
     Sub AddNewWorkbook2()
    
        Dim wkb As Workbook
    
        Set wkb = Workbooks.Add
        
        wkb.SaveAs "C:\Users\KARMAO2\Desktop\WorkbookName.xlsm", FileFormat:=52
        '52 = xlOpenXMLWorkbookMacroEnabled = xlsm (with macro's in 2007-2013)
        
        wkb.Close SaveChanges:=True
        
    End Sub
    Why doesnt my outlook code run both these macros?
    Last edited by wolfdemon710; 05-25-2015 at 12:49 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need a 2nd Outlook rule to trigger a 2nd script.
    By Agent-311 in forum Outlook Programming / VBA / Macros
    Replies: 6
    Last Post: 03-10-2015, 03:39 PM
  2. Outlook VBA running a script with a rule.
    By Rchie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2015, 11:23 AM
  3. [SOLVED] Running Up Outlook And VBA Script From a Scheduled Task
    By TheWarehouseGroupLtd in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2014, 05:12 PM
  4. Wanted: VBA Script to use for Outlook signatures
    By JDLM66062 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2013, 05:35 PM
  5. Can I trigger a VBA script without pausing Outlook for the duration?
    By baldmosher in forum Outlook Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2013, 07:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1