A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Runtime Error 13 - Type Mismatch



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 29th 07, 08:32 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default Runtime Error 13 - Type Mismatch

I've developed some code that will alter the subject line of an email
message selected in Outlook Explorer view based on a button clicked on
a custom toolbar.

I've succesfully delivered the code to 3 out of 5 user machines that
need the functionality - two machines that I'm having a problem with
are generating a Runtime Error 13 at the line in the {} brackets below
- ANY help would be greatly appreciated!

Public Sub ChangeSubjectLine()

Dim objApp As Outlook.Application
Dim GetCurrentItem As Outlook.MailItem
Dim ReplyCurrentItem As Outlook.MailItem
Dim CurrentSubject As String
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Dim WorkType As String
Dim ReplyBody As String
Dim AssigneeName As String
Dim AssigneeNum As String
Dim IncludeFolder As Boolean

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
{Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)}
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
' anything else will result in an error, which is
' why we have the error handler above
End Select

Code continues...

Thanks!
Jeff

  #2  
Old May 29th 07, 11:28 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Runtime Error 13 - Type Mismatch

It's possible for ActiveExplorer.Selection.Count to be 0 and for ActiveExplorer.Selection.Item(1) to be something other than a MailItem. You should take both into account.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

wrote in message oups.com...
I've developed some code that will alter the subject line of an email
message selected in Outlook Explorer view based on a button clicked on
a custom toolbar.

I've succesfully delivered the code to 3 out of 5 user machines that
need the functionality - two machines that I'm having a problem with
are generating a Runtime Error 13 at the line in the {} brackets below
- ANY help would be greatly appreciated!

Public Sub ChangeSubjectLine()

Dim objApp As Outlook.Application
Dim GetCurrentItem As Outlook.MailItem
Dim ReplyCurrentItem As Outlook.MailItem
Dim CurrentSubject As String
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Dim WorkType As String
Dim ReplyBody As String
Dim AssigneeName As String
Dim AssigneeNum As String
Dim IncludeFolder As Boolean

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
{Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)}
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
' anything else will result in an error, which is
' why we have the error handler above
End Select

Code continues...

Thanks!
Jeff

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error Mel Outlook Express 2 June 25th 06 05:43 AM
Runtime error 424 Graham Outlook and VBA 4 June 22nd 06 05:55 AM
Script Error - Type mismatch: 'Mycontrols' Line No. 415 sclark Outlook - Using Forms 2 April 13th 06 08:00 PM
runtime error! X chula819 Outlook Express 0 March 24th 06 08:28 AM
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


All times are GMT +1. The time now is 10:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.