Run-time error '92' For Loop Not Initialized

mlee3

Board Regular
Joined
May 6, 2008
Messages
70
Hi. I got an run-time error '02' for loop not initialized. Here are my codes and it ran through each item for a while and then stop at 'Next'. Appreciate if any one can help to check it out what the correct codes should be.

Sub ListAllContents()

Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olItem As MailItem
Dim rngOut1 As Range
Dim rngOut2 As Range
Dim rngOut3 As Range
Dim rngOut4 As Range
Dim rngOut5 As Range
Sheets("Data").Select
Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")

For Each olItem In olNamespace.Folders("Mailbox - TEST").Folders("Sent Items").Folders("TEST").Items
Dim LRow As Integer
LRow = Range("A65536").End(xlUp).Row + 1
Set rngOut1 = Range("A" & LRow)
Set rngOut2 = Range("B" & LRow)
Set rngOut3 = Range("C" & LRow)
Set rngOut4 = Range("D" & LRow)
Set rngOut5 = Range("E" & LRow)
Range("A1").FormulaR1C1 = "Contents"
Range("B1").FormulaR1C1 = "From"
Range("C1").FormulaR1C1 = "Sent"
Range("D1").FormulaR1C1 = "To"
Range("E1").FormulaR1C1 = "Subject"
On Error GoTo ErrHandler:
rngOut1 = olItem.Body
Set rngOut1 = rngOut1.Offset(1, 0)
rngOut2 = olItem.SenderName
Set rngOut2 = rngOut2.Offset(1, 0)
rngOut3 = olItem.SentOn
Set rngOut3 = rngOut3.Offset(1, 0)
rngOut4 = olItem.To
Set rngOut4 = rngOut4.Offset(1, 0)
rngOut5 = olItem.Subject
Set rngOut5 = rngOut5.Offset(1, 0)

Range("C2,E2").Select
Selection.Copy
Sheets("Recap").Select
Dim LRec As Integer
LRec = Range("A65536").End(xlUp).Row + 1
Range("A" & LRec).Select
ActiveSheet.Paste

Sheets("Data").Select
Call Convert
ErrHandler:
Next

Sheets("Edit Final").Select

Thanks!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Are you sure you have posted this in the correct section? Does this really have to do with the podcasts or MrExcel products? I do not have outlook, so I can't help you, but if it is posted in the proper forum someone else may be able to help.
 
Upvote 0

Forum statistics

Threads
1,225,476
Messages
6,185,202
Members
453,283
Latest member
Shortm88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top