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 / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Word 2003 and Outlook 2007 macro Run Time Error 13

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 21 Jan 2007 06:06 GMT
Run Time Error 13 Type Mismatch with Word 2003 and Outlook 2007? Does anyone
know what the problem is here? Help gives a variety of Debug Error etc but
nothing I can see? It worked fine the other day!!
At a loss...

Option Explicit

Private Sub UserForm_Initialize()

   Dim objOL As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim objFolder As MAPIFolder
   Dim c As Outlook.ContactItem

   Set objOL = New Outlook.Application
   Set objNS = objOL.GetNameSpace("MAPI")
   Set objFolder = objNS.GetDefaultFolder(olFolderContacts)
   For Each c In objFolder.Items
   ComboBox1.AddItem c.FullName & " - " & c.Email1Address
   Next
   ComboBox1.ListIndex = 0

   Set objOL = Nothing

End Sub

Private Sub cmdInsert_Click()

   Selection.TypeText ComboBox1.SelText

End Sub

Private Sub cmdClose_Click()
   Unload Me
End Sub
Perry - 21 Jan 2007 12:40 GMT
At first glance, nothing wrong with the code there...
So I copied the code and recreated the userform, and still not
able to reproduce ....

When y're in a session (in which this code fails) have you tried to step
through yr code in order to locate the offending VBA statement??

Krgrds,
Perry

> Run Time Error 13 Type Mismatch with Word 2003 and Outlook 2007? Does
> anyone know what the problem is here? Help gives a variety of Debug Error
[quoted text clipped - 31 lines]
>    Unload Me
> End Sub
Fred - 21 Jan 2007 13:13 GMT
Yes but shall do it again. I think Outlook 07 is misbehaving... back
soon....
> At first glance, nothing wrong with the code there...
> So I copied the code and recreated the userform, and still not
[quoted text clipped - 41 lines]
>>    Unload Me
>> End Sub
Perry - 21 Jan 2007 13:26 GMT
>>    ComboBox1.AddItem c.FullName & " - " & c.Email1Address

Still not able to reproduce but:
The above line will most definitely be the heartbreaker ...

Try to pass c.FullName and c.Email1Address to a seperate variable
of type String. Do the concatenation of both strings into another variable
of type String and AddItem the combined variable to ComboBox1

Krgrds,
Perry

> Yes but shall do it again. I think Outlook 07 is misbehaving... back
> soon....

>> At first glance, nothing wrong with the code there...
>> So I copied the code and recreated the userform, and still not
[quoted text clipped - 41 lines]
>>>    Unload Me
>>> End Sub
Graham Mayor - 21 Jan 2007 15:46 GMT
Have you added the Outlook 2007 object library to Word's vba - if indeed it
is available to add?

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Yes but shall do it again. I think Outlook 07 is misbehaving... back
> soon....
[quoted text clipped - 43 lines]
>>>    Unload Me
>>> End Sub
Perry - 21 Jan 2007 16:09 GMT
He wouldn't even get to the 13 Mismatch error, instead the VBA compiler
throws in "User Defined Type Unknown" or "Function Not Recognised" error
messages.

So you can fairly assume a reference to Outlook being set.

Krgrds,
Perry

> Have you added the Outlook 2007 object library to Word's vba - if indeed
> it is available to add?
[quoted text clipped - 46 lines]
>>>>    Unload Me
>>>> End Sub
 
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.