End With ohne With
08.05.2013 11:13:44
Hans
ich habe folgenden Code für das Auslesen von Mails. Bekomme allerdings die Fehlermeldung "End With ohne With"
Was muss ich denn ändern?
VG Hans
Sub Posteingang()
Dim OLF As Outlook.MAPIFolder, CurrUser As String
Dim EmailItemCount As Integer, i As Integer, EmailCount As Integer
Application.ScreenUpdating = False
Sheets.Add
Cells(1, 1).Formula = "Betreff"
Cells(1, 2).Formula = "Empfangen am"
Cells(1, 3).Formula = "Anhänge"
Cells(1, 4).Formula = "gelesen"
Range("A1:D1").Font.Bold = True
Set OLF = GetObject("", "Outlook.Application") _
.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
EmailItemCount = OLF.Items.Count
i = 0
EmailCount = 0
While i "" Then
Cells(EmailCount + 1, 2).Value = Format(.ReceivedTime, _
"dd.mm.yyyy hh:mm")
Cells(EmailCount + 1, 3).Formula = .Attachments.Count
If .UnRead Then
Cells(EmailCount + 1, 4).Formula = "Nein"
Else
Cells(EmailCount + 1, 4).Formula = "Ja"
End If
End With
Wend
Application.Calculation = xlCalculationAutomatic
Set OLF = Nothing
Columns("A:D").AutoFit
ActiveWindow.FreezePanes = True
Application.StatusBar = False
End Sub