Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

End With ohne With

Forumthread: End With ohne With

End With ohne With
08.05.2013 11:13:44
Hans
Hallo liebe Forumsteilnehmer,
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

Anzeige

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Dann mit With =)
08.05.2013 11:21:57
JACKD
Die Fehlermeldung sagt dir ja schon was das Problem ist..
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
End if '''Hier einfügen..?
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
Ich glaub du musst die eine If schleife noch abschliessen

Anzeige
AW: Dann mit With =)
08.05.2013 11:33:32
Hans
Super geht Vielen Dank!

Danke für die Rückmeldung owT.
08.05.2013 11:38:08
JACKD
.
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige