![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi all,
In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes |
Ads |
#2
|
|||
|
|||
![]()
So, let's play detective. If the code works on some mail items but not
others I'd doubt it's a problem that can be solved by repair/reinstall/whatever, see if there are differences that you can find with the items where the macro works and where it doesn't. The other thing to check is why you're getting an error of MAPI_E_NOT_FOUND for those items. Google on that error code and see if any of the reasons that you're getting MAPI_E_NOT_FOUND apply to you. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm wrote in message ps.com... Hi all, In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes |
#3
|
|||
|
|||
![]()
On 4 Okt., 16:50, "Ken Slovak - [MVP - Outlook]"
wrote: So, let's play detective. If the code works on some mail items but not others I'd doubt it's a problem that can be solved by repair/reinstall/whatever, see if there are differences that you can find with the items where the macro works and where it doesn't. The other thing to check is why you're getting an error of MAPI_E_NOT_FOUND for those items. Google on that error code and see if any of the reasons that you're getting MAPI_E_NOT_FOUND apply to you. -- Ken Slovak [MVP - Outlook]http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm wrote in message ps.com... Hi all, In VBA, when trying this: dim mi as Outlook.MailItem set mi = Application.ActiveExplorer.Selection.Item(1) ' Here, Error 13 - Type mismatch occurs I get a type mismatch error. If I declare mi as Object instead of MailItem, the erroneous line works, but later when accessing properties like mi.SenderName or functions like mi.SaveAs(), the function crashes ("the function 'SaveAs' of object 'MailItem' failed. Error Code: 8004010f"). When I examine the mi object, it says that it is of type MailItem. mi.Class returns olMailItem (43), TypeName(mi) returns "MailItem", etc. Curiously, e.g. mi.Subject and mi.Class properties return correct values, while mi.SenderName fails as mi.SaveAs() does. Strangely, this does not happen for every Mail I select when running the macro, and running the macro on another machine can but does not always succeed. The behaviour seems completely random. All machines are running Windows XP SP2 with latest updates and Office 2003 SP2 accessing an Exchange Server 2003. Reading through this group there are some people who faced the same problem, but since some properties work on the MailItem object, most people didn't care about late binding and using the working properties. In my case I have to use the SaveAs function which crashes as described above. Any hints/workarounds/cheats/whatever? Could it be an installation issue? Reinstalling Office didn't help. Thanks in advance. Kind Regards, Hannes Thanks for your reply. Since some MailItems work on one machine but not one the other, I guess it could be an installation or configuration issue - not necessarily with Office itself, but perhaps with any other software? I'll try installing SP3 or using an older or newer Outlook version (2002 or 2007), maybe it works then. I didn't find anything on the web concerning my issue and the MAPI_E_NOT_FOUND error that would bring any hints. The messages that don't work show no difference to me from the ones that work - I can use/modify them directly in Outlook with no problems. Only in VBA they seem to differ. Strange behaviour. Thanks in advance. Regards, Hannes |
#4
|
|||
|
|||
![]()
If you have a MAPI viewer such as OutlookSpy (www.dimastr.com) it often
shows differences in properties that you don't see in the user interface. I'd also suspect permissions issues possibly if the code works with the same items on one setup and not the other. See that the permissions are for the users represented by those Outlook logons. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm wrote in message oups.com... snip Thanks for your reply. Since some MailItems work on one machine but not one the other, I guess it could be an installation or configuration issue - not necessarily with Office itself, but perhaps with any other software? I'll try installing SP3 or using an older or newer Outlook version (2002 or 2007), maybe it works then. I didn't find anything on the web concerning my issue and the MAPI_E_NOT_FOUND error that would bring any hints. The messages that don't work show no difference to me from the ones that work - I can use/modify them directly in Outlook with no problems. Only in VBA they seem to differ. Strange behaviour. Thanks in advance. Regards, Hannes |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Run-time Error '13' Type mismatch | RS | Outlook and VBA | 9 | September 28th 07 06:22 PM |
Please help on this VBA macro. Error 13, type mismatch | John Z | Outlook and VBA | 3 | August 15th 07 09:36 PM |
Runtime Error 13 - Type Mismatch | [email protected] | Outlook and VBA | 1 | May 29th 07 11:28 PM |
Script Error - Type mismatch: 'Mycontrols' Line No. 415 | sclark | Outlook - Using Forms | 2 | April 13th 06 08:00 PM |
Why do I get a type mismatch when trying to access mail items? | Pete Dawson (Leeds Uni) | Outlook and VBA | 3 | March 3rd 06 01:16 PM |