A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: ,

binding...





 
 
Thread Tools Display Modes
  #11  
Old July 17th 07, 10:48 PM posted to microsoft.public.outlook.program_vba
Jonathan
external usenet poster
 
Posts: 46
Default binding...



"Michael Bauer [MVP - Outlook]" wrote:


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


Hi Michael, yes I have changed the code as you suggested and yes it still
fails at the line

Prop.Value = fld.Value

I appreciate your attempts. It's still a mystery why this line works when I
reference Outlook objects and does not work when I declare variables as
[generic] objects...

Many thanks, Jonathan

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






Ads
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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 11:02 PM
Early binding and late binding with attachment Jonathan Outlook and VBA 2 June 9th 06 03:24 AM
Late binding sample John Outlook - General Queries 3 February 24th 06 10:32 PM
Late binding sample John Outlook and VBA 3 February 24th 06 10:32 PM


All times are GMT +1. The time now is 06:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Credit Counseling - Debt Consolidation - Credit Cards - Remortgaging - Credit Cards