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.
Bookmarks