Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / May 2007

Tip: Looking for answers? Try searching our database.

Runtime Error 13 - Type Mismatch

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JeffSnead@gmail.com - 29 May 2007 20:32 GMT
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
Sue Mosher [MVP-Outlook] - 29 May 2007 23:28 GMT
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.

Signature

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
 

> 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
[quoted text clipped - 38 lines]
> Thanks!
> Jeff
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.