J
Jeff
Here is the code:
Set myolApp = Outlook.Application
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.PickFolder
Dim oMailItem As MailItem
frmSaveStatus.Show
SaveFolder = "c:\Attachments\"
frmSaveStatus.lblItems.Caption = myFolder.Items.Count
myCounter = 0
For Each oMailItem In myFolder.Items
myCounter = myCounter + 1
frmSaveStatus.lblComplete.Caption = myCounter
If myFolder.Items.Count = 0 Then
' Do Nothing
Else
frmSaveStatus.lblPercentage = myCounter /
myFolder.Items.Count
End If
frmSaveStatus.Repaint
If oMailItem.Attachments.Count > 0 Then
For Each myattachment In oMailItem.Attachments
frmSaveStatus.lblFileName = myattachment.FileName
frmSaveStatus.lblFrom = oMailItem.Subject
frmSaveStatus.lblDate = oMailItem.Size
Select Case LCase(Right(myattachment.FileName, 3))
Case "msg":
GoTo EndFor1:
Case Else:
myattachment.SaveAsFile SaveFolder &
myattachment.FileName
End Select
EndFor1:
Next myattachment
End If
Next '<-Type Mismatch on Item #406 of 416!!!?
frmSaveStatus.Hide
Set objWord = Nothing
Set dlg = Nothing
Set objOL = Nothing
Set objOLWindow = Nothing
End Sub
OK, this has a lot of stuff in it that doesn't need to be there, but
after a certain number of executions (Say, mFolder.Items.Count=416, I
get the error at item #406), I get a Type Mismatch error on the Next
line indicated in the code.
I'm a newbie, so please help directly, and please assume (as Schultz
would say I know NOTHING!!!
Thanks,
Jeff
Set myolApp = Outlook.Application
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.PickFolder
Dim oMailItem As MailItem
frmSaveStatus.Show
SaveFolder = "c:\Attachments\"
frmSaveStatus.lblItems.Caption = myFolder.Items.Count
myCounter = 0
For Each oMailItem In myFolder.Items
myCounter = myCounter + 1
frmSaveStatus.lblComplete.Caption = myCounter
If myFolder.Items.Count = 0 Then
' Do Nothing
Else
frmSaveStatus.lblPercentage = myCounter /
myFolder.Items.Count
End If
frmSaveStatus.Repaint
If oMailItem.Attachments.Count > 0 Then
For Each myattachment In oMailItem.Attachments
frmSaveStatus.lblFileName = myattachment.FileName
frmSaveStatus.lblFrom = oMailItem.Subject
frmSaveStatus.lblDate = oMailItem.Size
Select Case LCase(Right(myattachment.FileName, 3))
Case "msg":
GoTo EndFor1:
Case Else:
myattachment.SaveAsFile SaveFolder &
myattachment.FileName
End Select
EndFor1:
Next myattachment
End If
Next '<-Type Mismatch on Item #406 of 416!!!?
frmSaveStatus.Hide
Set objWord = Nothing
Set dlg = Nothing
Set objOL = Nothing
Set objOLWindow = Nothing
End Sub
OK, this has a lot of stuff in it that doesn't need to be there, but
after a certain number of executions (Say, mFolder.Items.Count=416, I
get the error at item #406), I get a Type Mismatch error on the Next
line indicated in the code.
I'm a newbie, so please help directly, and please assume (as Schultz
would say I know NOTHING!!!
Thanks,
Jeff