PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: elementary VBA code
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: elementary VBA code
![]() |
Re: elementary VBA code |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Besides contact items (ContactItem), you can also have distribution lists
(DistListItem) objects in the Contacts folder. Modify your code as follows (dim MyContactItem as Object and check the value of the Class property to make sure you have a ContactItem object) 1.Public Sub AddFax() 2. Dim MyContactFolder As MAPIFolder 3. Dim MyContactItem As Object 4. Set MyContactFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts) 5. For Each MyContactItem In MyContactFolder.Items 5a If MyContactItem.Class = 40 Then 6. If MyContactItem.BusinessFaxNumber <> "" Then ......... 7. MyContactItem.Save 8. End If 8a End If 9. Next 10.End Sub Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Meenu Hodiwalla" <meenu_hodiwalla@bluemail.ch> wrote in message news:958d01c37fb7$1e578220$a601280a@phx.gbl... > I copied the following VBA code from a book : > > 1.Public Sub AddFax() > 2. Dim MyContactFolder As MAPIFolder > 3. Dim MyContactItem As ContactItem > 4. Set MyContactFolder = Application.GetNamespace > ("MAPI").GetDefaultFolder(olFolderContacts) > 5. For Each MyContactItem In MyContactFolder.Items > 6. If MyContactItem.BusinessFaxNumber <> "" Then > ......... > 7. MyContactItem.Save > 8. End If > 9. Next > 10.End Sub > > But I get run time error 13 (type mismatch) for line 5 of > this code. Can anyone help ? > Thanks. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

