woytek00
03-20-2012, 03:43 AM
why error appears: 424 object required for below code
Sub test()
Dim msg as Object
If TypeOf msg Is MailItem Then
MsgForMailItem (msg) ' here is OK
ElseIf TypeOf msg Is ReportItem Then
MsgForReportItem (msg) ' here error appears: 424 Object required
End If
End Sub
Function MsgForReportItem (ri as Object)
MsgBox "Report"
' ... another action
End Function
Function msgForMailItem (mi as Object)
MsgBox "Mail"
' ... another action
End Function
Sub test()
Dim msg as Object
If TypeOf msg Is MailItem Then
MsgForMailItem (msg) ' here is OK
ElseIf TypeOf msg Is ReportItem Then
MsgForReportItem (msg) ' here error appears: 424 Object required
End If
End Sub
Function MsgForReportItem (ri as Object)
MsgBox "Report"
' ... another action
End Function
Function msgForMailItem (mi as Object)
MsgBox "Mail"
' ... another action
End Function