Results 1 to 4 of 4

Thread: Save attached excel files according to certain variables

  1. #1
    Neophyte Friedrichsen's Avatar
    Join Date
    Dec 2011
    Location
    Copenhagen
    Posts
    3
    Articles
    0

    Save attached excel files according to certain variables



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello

    I am new to this forum, so forgive me if this is the wrong subforum for this problem.

    I have a dreadful and repetitive routine in my job. Every monday i get 2x17 emails with excelfiles that I must save, merge and report to the management.

    I am hoping to eliminate the plethra of clicks that relate to doing this mindnumbing task.

    Is there a way to save an attachment with a predefined name, according to, lets say, a registry of email-adresses?

    Hope it made sence.

    Cheers

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,091
    Articles
    79
    Blog Entries
    14
    Sure, what email client are you using?
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Neophyte Friedrichsen's Avatar
    Join Date
    Dec 2011
    Location
    Copenhagen
    Posts
    3
    Articles
    0
    I use both Microsoft Outlook and Gmail, but a solution for outlook is preferred.

  4. #4
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,091
    Articles
    79
    Blog Entries
    14
    Curious...

    Can you set up a rule in Outlook to filter those messages to go directly into a specific folder? If so you could use the following routine (adpated from http://www.vbaexpress.com/kb/getarticle.php?kb_id=522)

    Code:
     '###############################################################################
     '### Module level Declarations
     'expose the items in the target folder to events
    Option Explicit
    
    Dim WithEvents TargetFolderItems As Items 
     'set the string constant for the path to save attachments
    Const FILE_PATH As String = "C:\Temp\"
    Const OUTLOOK_FOLDER as String = "Temp"
    
     '###############################################################################
     '### this is the Application_Startup event code in the ThisOutlookSession module
    Private Sub Application_Startup() 
         'some startup code to set our "event-sensitive" items collection
        Dim ns As Outlook.NameSpace
    
        Set ns = Application.GetNamespace("MAPI") 
        Set TargetFolderItems = ns.Folders.Item( _ 
        "Personal Folders").Folders.Item(OUTLOOK_FOLDER).Items
        
    End Sub 
    
     '###############################################################################
     '### this is the ItemAdd event code
    Sub TargetFolderItems_ItemAdd(ByVal Item As Object) 
         'when a new item is added to our "watched folder" we can process it
        Dim olAtt As Attachment 
        Dim i As Integer
      
        If Item.Attachments.Count > 0 Then 
            For i = 1 To Item.Attachments.Count 
                Set olAtt = Item.Attachments(i) 
                 'save the attachment
                olAtt.SaveAsFile FILE_PATH & olAtt.FileName
               
                End If 
            Next 
        End If 
    
        Set olAtt = Nothing
       
    End Sub
    
    '###############################################################################
     '### this is the Application_Quit event code in the ThisOutlookSession module
    Private Sub Application_Quit()
         
        Dim ns As Outlook.NameSpace 
        Set TargetFolderItems = Nothing 
        Set ns = Nothing 
     
    End Sub
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/forums
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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