![]() |
| 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. |
|
|||||||
| Tags: binding, gtgt |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi, I'm updating public folder contacts from MS Access. When I have a
reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
| Ads |
|
#2
|
|||
|
|||
|
Does this work any better in the late bound code:
myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#3
|
|||
|
|||
|
"Ken Slovak - [MVP - Outlook]" wrote:
Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#4
|
|||
|
|||
|
Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.)
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#5
|
|||
|
|||
|
"Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#6
|
|||
|
|||
|
Is it possible that it doesn't happen with every recordset, and early-/late binding doesn't really matter? One source for such an error would be that fld.Value is an object. In that case the Set statement is misssing: Set myContact.ItemProperties.Item(strOlField).Value = fld.value Additionally, I'd recommend to always write the property name. Item(strOlField) is an object, but actually you don't want to set that object but write something into its Value property. If fld.value is an object then VB can't know that you actually want to access the Item's default property, and this would be twice an error: myContact.ItemProperties.Item(strOlField) = fld.value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Wed, 11 Jul 2007 17:26:02 -0700 schrieb Jonathan: "Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#7
|
|||
|
|||
|
"Michael Bauer [MVP - Outlook]" wrote: Is it possible that it doesn't happen with every recordset, and early-/late binding doesn't really matter? One source for such an error would be that fld.Value is an object. In that case the Set statement is misssing: Set myContact.ItemProperties.Item(strOlField).Value = fld.value Additionally, I'd recommend to always write the property name. Item(strOlField) is an object, but actually you don't want to set that object but write something into its Value property. If fld.value is an object then VB can't know that you actually want to access the Item's default property, and this would be twice an error: myContact.ItemProperties.Item(strOlField) = fld.value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Thanks Michael for this. fld.Value is definitely a value. This routine works with the same recordset when object variables are declared as Outlook objects. When object variables are set to simple objects this routine fails. I sure that there is a logical reason for it... I just can't recognise it... Many thanks, Jonathan Am Wed, 11 Jul 2007 17:26:02 -0700 schrieb Jonathan: "Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#8
|
|||
|
|||
|
Of course is fld.Value a Value But that property is a Variant and may also reference an object. I don't remember the name for that type of query but a specific sql query returns a recordset within a recordset's Field object. That is, fld.Value would be an object and not a string or whatever. Do you test the late binding also with OL07 or with OL03? This is what I'd do next: - change the code - to know exactly what line causes the error: Dim Props as Object Dim Prop as Object Set Props=myContact.ItemProperties Set Prop=Props(strOlField) Prop.Value=fld.Value - add a Debug statement - just to be very sure...: Debug.Print TypeName(fld.Value) Prop.Value=fld.Value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Thu, 12 Jul 2007 14:04:03 -0700 schrieb Jonathan: "Michael Bauer [MVP - Outlook]" wrote: Is it possible that it doesn't happen with every recordset, and early-/late binding doesn't really matter? One source for such an error would be that fld.Value is an object. In that case the Set statement is misssing: Set myContact.ItemProperties.Item(strOlField).Value = fld.value Additionally, I'd recommend to always write the property name. Item(strOlField) is an object, but actually you don't want to set that object but write something into its Value property. If fld.value is an object then VB can't know that you actually want to access the Item's default property, and this would be twice an error: myContact.ItemProperties.Item(strOlField) = fld.value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Thanks Michael for this. fld.Value is definitely a value. This routine works with the same recordset when object variables are declared as Outlook objects. When object variables are set to simple objects this routine fails. I sure that there is a logical reason for it... I just can't recognise it... Many thanks, Jonathan Am Wed, 11 Jul 2007 17:26:02 -0700 schrieb Jonathan: "Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#9
|
|||
|
|||
|
"Michael Bauer [MVP - Outlook]" wrote: Of course is fld.Value a Value But that property is a Variant and may also reference an object. I don't remember the name for that type of query but a specific sql query returns a recordset within a recordset's Field object. That is, fld.Value would be an object and not a string or whatever. Do you test the late binding also with OL07 or with OL03? This is what I'd do next: - change the code - to know exactly what line causes the error: Dim Props as Object Dim Prop as Object Set Props=myContact.ItemProperties Set Prop=Props(strOlField) Prop.Value=fld.Value - add a Debug statement - just to be very sure...: Debug.Print TypeName(fld.Value) Prop.Value=fld.Value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Hi Michael, Attempting this with Ol07 and Ol03. Same outcome. Debug.Print fld.Value returns 1 Debug.Print TypeName(fld.Value) returns Long Many thanks, Jonathan Am Thu, 12 Jul 2007 14:04:03 -0700 schrieb Jonathan: "Michael Bauer [MVP - Outlook]" wrote: Is it possible that it doesn't happen with every recordset, and early-/late binding doesn't really matter? One source for such an error would be that fld.Value is an object. In that case the Set statement is misssing: Set myContact.ItemProperties.Item(strOlField).Value = fld.value Additionally, I'd recommend to always write the property name. Item(strOlField) is an object, but actually you don't want to set that object but write something into its Value property. If fld.value is an object then VB can't know that you actually want to access the Item's default property, and this would be twice an error: myContact.ItemProperties.Item(strOlField) = fld.value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Thanks Michael for this. fld.Value is definitely a value. This routine works with the same recordset when object variables are declared as Outlook objects. When object variables are set to simple objects this routine fails. I sure that there is a logical reason for it... I just can't recognise it... Many thanks, Jonathan Am Wed, 11 Jul 2007 17:26:02 -0700 schrieb Jonathan: "Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
#10
|
|||
|
|||
|
If you chaged the code as suggested and it's still then line Prop.Value=fld.Value then I'm out of ideas. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Sun, 15 Jul 2007 13:50:00 -0700 schrieb Jonathan: "Michael Bauer [MVP - Outlook]" wrote: Of course is fld.Value a Value But that property is a Variant and may also reference an object. I don't remember the name for that type of query but a specific sql query returns a recordset within a recordset's Field object. That is, fld.Value would be an object and not a string or whatever. Do you test the late binding also with OL07 or with OL03? This is what I'd do next: - change the code - to know exactly what line causes the error: Dim Props as Object Dim Prop as Object Set Props=myContact.ItemProperties Set Prop=Props(strOlField) Prop.Value=fld.Value - add a Debug statement - just to be very sure...: Debug.Print TypeName(fld.Value) Prop.Value=fld.Value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Hi Michael, Attempting this with Ol07 and Ol03. Same outcome. Debug.Print fld.Value returns 1 Debug.Print TypeName(fld.Value) returns Long Many thanks, Jonathan Am Thu, 12 Jul 2007 14:04:03 -0700 schrieb Jonathan: "Michael Bauer [MVP - Outlook]" wrote: Is it possible that it doesn't happen with every recordset, and early-/late binding doesn't really matter? One source for such an error would be that fld.Value is an object. In that case the Set statement is misssing: Set myContact.ItemProperties.Item(strOlField).Value = fld.value Additionally, I'd recommend to always write the property name. Item(strOlField) is an object, but actually you don't want to set that object but write something into its Value property. If fld.value is an object then VB can't know that you actually want to access the Item's default property, and this would be twice an error: myContact.ItemProperties.Item(strOlField) = fld.value -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Organize eMails: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Thanks Michael for this. fld.Value is definitely a value. This routine works with the same recordset when object variables are declared as Outlook objects. When object variables are set to simple objects this routine fails. I sure that there is a logical reason for it... I just can't recognise it... Many thanks, Jonathan Am Wed, 11 Jul 2007 17:26:02 -0700 schrieb Jonathan: "Sue Mosher [MVP-Outlook]" wrote: Do you have olContactItem declared somewhere as a constant? If not, that could be the problem -- the item you're creating will be a MailItem, not a ContactItem because olContactItem will equal zero. (Option Explicit does wonders for rooting out these little problems.) -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 Thanks Sue, yes I have all my Outlook constants declared in General Declarations section. I really do appologise for not including this in the background info of my questions. Private Const olContactItem = 2 Many thanks, Jonathan "Jonathan" wrote in message ... "Ken Slovak - [MVP - Outlook]" wrote: Does this work any better in the late bound code: myContact.ItemProperties.Item(strOlField) = fld.Value -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm Thanks for the idea. sighUnfortunitly it still generates the same error/sigh . Many thanks Jonathan "Jonathan" wrote in message ... Hi, I'm updating public folder contacts from MS Access. When I have a reference to the Outlook Object Library the routine does its thing. However I'm using Outlook 12 and the other users have Outlook 11. So I want to remove the reference to the Outlook Object Library and declare variables as [generic] objects instead of outlook.objects. Unfortunitely it now fails... The following is the code snippet (contained within a loop of a recordset) with the problem. Background is I have a table that maps outlook contact fields to database fields. The code retreives (strOlField) the appropriate outlook contact field for data insertion. 'Insert an outlook for each database contact Set myContact = myContactItems.Add(olContactItem) For Each fld In .Fields If Not IsNull(fld.Value) Then strOlField = getOutlookField(fld.Name, strColumn) If Len(strOlField) 0 Then myContact.ItemProperties(strOlField) = fld.Value End If End If DoEvents Next fld The line myContact.ItemProperties(strOlField) = fld.Value generates "Error 450 (Wrong number of arguments or invalid property assignment)..." This error does not occur when using early binding. Any ideas or suggestion appreciated :-) Many thanks, Jonathan |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binding a Control to an ADODC Control, Is it possible | Andrew Sampels | Outlook - Using Forms | 1 | August 8th 06 10:02 PM |
| Early binding and late binding with attachment | Jonathan | Outlook and VBA | 2 | June 9th 06 02:24 AM |
| Late binding sample | John | Outlook - General Queries | 3 | February 24th 06 09:32 PM |
| Late binding sample | John | Outlook and VBA | 3 | February 24th 06 09:32 PM |