![]() |
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
|
|||
|
|||
![]()
I have created a macro for copying 140 contactitems. The macro was created
under Outlook 2003 (Vbaoject.OTM). When I run this macro, it successfully copies around 125 rows and then abends. The Err.Description contains "Automation Error, Unspecified Error". Then I run the same macro in the debugger and set a breakpoint at the copy of row 125 to capture the error, everything works fine and it continues to copy all 140 contactitems. As another test, I created the exact same macro under a Word document and it runs to completion. The code follows: Option Explicit Private ol As Object Private olns As Object Private AllItems As Object Private Itm As Object Private Sub CopyToButton_Click() Dim myItem As Object Dim i As Integer Dim projectNameFrom, projectNameTo As String On Error Resume Next Set ol = New Outlook.Application Set olns = ol.GetNamespace("MAPI") projectNameFrom = "James Test 5" projectNameTo = "James Test 1" i = 0 Set AllItems = olns.GetDefaultFolder(18).Folders("TBS Applications").Folders("CRM").Folders("Event Contacts").Items.Restrict("[Event Name] = """ & projectNameFrom & """") For Each Itm In AllItems i = i + 1 Set myItem = olns.GetDefaultFolder(18).Folders("TBS Applications").Folders("CRM").Folders("Event Contacts").Items.Add myItem.UserProperties.Find("Event Name") = projectNameTo myItem.JobTitle = Itm.JobTitle myItem.FullName = Itm.FullName myItem.CompanyName = Itm.CompanyName myItem.Email1Address = Itm.Email1Address myItem.BusinessTelephoneNumber = Itm.BusinessTelephoneNumber myItem.UserProperties.Find("Participation Status").Value = "Invited" myItem.Save If Err Then MsgBox "failed on row: " + i MsgBox Err.Description Exit Sub End If Next MsgBox "Done" Set ol = Nothing Set olns = Nothing Set myItem = Nothing Set AllItems = Nothing Set Itm = Nothing End Sub The contactitems being copied are associated with a custom form. Any ideas? -- James |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Call macro stored in Excel workbook from Outlook's macro | Gvaram | Outlook and VBA | 5 | October 4th 06 06:26 AM |
Macro runs on startup | jbc | Outlook - Installation | 1 | September 20th 06 07:40 PM |
Macro to search for word | Dave Neve | Outlook and VBA | 7 | July 26th 06 09:52 PM |
Create a macro that runs from a Rule | CF_business_analyst | Outlook and VBA | 8 | January 13th 06 05:12 PM |