Problemer med at compile, fejler på Excel.Application
HejJeg har fået en kode(http://youtu.be/3HOsWA1-quQ) af Jie Jenn som virker på hans outlook 2010, men på min fejler den.
Den fejler med : Compile Error:User-defined type not defined
Nedenfor er video link samt kode.
Til info så har jeg installeret excel library "Microsoft Office 14.0 Object Library" i mit excel, samt installeret "Microsoft Outlook 14.0 Object Library" og "Microsoft Office 14.0 Object Library" i min outlook.
http://youtu.be/G8CQEdbznaU
Sub ListOutlookEmailInfoInExcel()
Dim o1NS As Outlook.NameSpace
Dim o1TaskFolder As Outlook.MAPIFolder
Dim o1Task As Outlook.TaskItem
Dim o1Items As Outlook.Items
Dim x1App As Excel.Application
Dim x1WB As Excel.Workbook
Dim x As Long
Dim arrHeaders As Variant
Set o1NS = GetNamespace("MAPI")
Set o1TaskFolder = o1NS.GetDefaultFolder(olFolderInbox)
Set o1Items = o1TaskFolder.Items
Set x1App = CreateObject("Excel.Application")
x1App.Visible = True
Set x1WB = x1App.Workbooks.Add
On Error Resume Next
x = 2
arrHeaders = Array("Date Created", "Date Received", "Subject", "Sender", "Sender's Email", "CC", _
"Sender's Email Type", "MSG Size", "Unread?")
x1WB.Worksheets(1).Range("A1").Resize(1, UBound(arrHeaders)).Value = ""
Do
With x1WB.Worksheets(1)
If Not (o1Items(x).Subject = "" And o1Items(x).CreationTime = "") Then
.Range("A1").Resize(1, UBound(arrHeaders) + 1) = arrHeaders
.Cells(x, 1).Value = o1Items(x).CreationTime
.Cells(x, 2).Value = o1Items(x).ReceivedTime
.Cells(x, 3).Value = o1Items(x).Subject
.Cells(x, 4).Value = o1Items(x).SenderName
.Cells(x, 5).Value = o1Items(x).SenderEmailAddress
.Cells(x, 6).Value = o1Items(x).CC
.Cells(x, 7).Value = o1Items(x).SenderEmailType
.Cells(x, 8).Value = Format((o1Items(x).Size / 1024) / 1024, "#, ##0.00") & " MB"
.Cells(x, 9).Value = o1Items(x).UnRead
x = x + 1
End If
End With
Loop Until x >= o1Items.Count + 1
Set o1NS = Nothing
Set o1TaskFolder = Nothing
Set o1Items = Nothing
Set x1App = Nothing
Set x1WB = Nothing
End Sub