+ Reply to Thread
Results 1 to 6 of 6

problem with macro - trying to extract subjects from .msg files stored in folder

Hybrid View

mwilkes problem with macro - trying... 12-10-2013, 06:33 PM
Norie Re: problem with macro -... 12-10-2013, 06:45 PM
mwilkes Re: problem with macro -... 12-10-2013, 06:52 PM
Norie Re: problem with macro -... 12-10-2013, 06:57 PM
mwilkes Re: problem with macro -... 12-10-2013, 06:59 PM
mwilkes Re: problem with macro -... 12-10-2013, 07:06 PM
  1. #1
    Registered User
    Join Date
    10-08-2013
    Location
    california
    MS-Off Ver
    Excel 2010
    Posts
    27

    problem with macro - trying to extract subjects from .msg files stored in folder

    I pulled this code off the net:

    Option Explicit
    'MUST set reference to Microsoft Outlook Object Library
    'See Tools/References on main menu bar of VBE
    'Could also use Late Binding, if necessary
    
    Sub macro2()
        Dim olA As Outlook.Application
        Dim olMI As Object 'not as Mail Item
        Dim aPaths() As String 'paths to *.msg files
        Dim vSubjects() As Variant 'list of subjects
        Dim vSelItems As Variant 'to get selected items
        Dim i As Long
        Dim rDest As Range 'where Subject lines will be written
    
    Set olA = New Outlook.Application
    Set rDest = Range("B1")
    
    'Select the files to process
    With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = True
        .Filters.Add "Messages", "*.msg", 1
        .FilterIndex = 1
        If .Show = -1 Then
            ReDim aPaths(0 To .SelectedItems.Count - 1)
            For i = 0 To .SelectedItems.Count - 1
                aPaths(i) = .SelectedItems(i + 1)
            Next i
        End If
    End With
    
    Application.ScreenUpdating = False
    rDest.EntireColumn.Clear
    With rDest(1, 1)
        .Value = "Subjects"
        .Font.Bold = True
    End With
    
    ReDim vSubjects(1 To UBound(aPaths) + 1, 1 To 1)
    For i = 0 To UBound(aPaths)
        vSubjects(i + 1, 1) = olA.CreateItemFromTemplate(aPaths(i)).Subject
    Next i
    
    Set rDest = rDest.Offset(rowoffset:=1).Resize(rowsize:=UBound(vSubjects))
    rDest = vSubjects
    rDest.EntireColumn.AutoFit
    
    Application.ScreenUpdating = True
    Set olA = Nothing
    
    End Sub
    I am getting "Run-time error '-2147467229 (80004023)': Automation Error A microsoft software installer error has occurred" on: Set olA = New Outlook.Application

    Why is this happening? I am on office 2010 and have outlook object references set.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: problem with macro - trying to extract subjects from .msg files stored in folder

    What happens if you replace that line with this?
    Set olA = CreateObject("Outlook.Application")
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-08-2013
    Location
    california
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: problem with macro - trying to extract subjects from .msg files stored in folder

    same thing

    debugger is showing ola = nothing
    Last edited by mwilkes; 12-10-2013 at 06:56 PM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: problem with macro - trying to extract subjects from .msg files stored in folder

    I'm afraid I can't find anything on that specific error but it kind of sounds like there's a problem with your installation of Office/Outlook.

  5. #5
    Registered User
    Join Date
    10-08-2013
    Location
    california
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: problem with macro - trying to extract subjects from .msg files stored in folder

    its office 2010 64bit, never had any issues with it.

    Do you know of another way to extract the subject lines of .msg files stored in a windows folder (not an outlook folder)?

  6. #6
    Registered User
    Join Date
    10-08-2013
    Location
    california
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: problem with macro - trying to extract subjects from .msg files stored in folder

    Fixed it. Registry problem. I had 2007 before 2010.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need Help for creating a Macro to extract specific data from all files in a folder.
    By shaiq123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2013, 02:08 PM
  2. Extract files from a folder using the names listed in a excel
    By firdausvariava in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2012, 08:34 AM
  3. [SOLVED] How to Extract .zip files stored in a folder using VBA
    By zaska in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2012, 01:24 PM
  4. Macro to extract files in a given Folder
    By jmtwentynine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2012, 02:41 AM
  5. Copy a row from 3000 excel files stored in a folder and paste it in a new workbook
    By hubertus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2009, 10:34 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