-
August 7th, 2002, 03:45 AM
#1
how to detect value not valid
Hi.
I am looping through the properties of an object (Outlook COntactObject) and I get an error -
"Cant complete operation. One of the object parameters is not valid"
this object parameter is here :
myContact.ItemProperties.Item(ContactPropCounter).Value
for some properties there are no .Value.
Question:
is there a way to detect in
myContact.ItemProperties.Item(ContactPropCounter).Value is valid so that I can skip it and continue looping through other properties?
Thanks.
This forum is the best.
-_-_-_-_-_-_
AM
-
August 7th, 2002, 07:28 AM
#2
did you try...
on error resume next
....
myContact.ItemProperties.Item(ContactPropCounter).Value
.....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 7th, 2002, 08:18 AM
#3
Yes. Somehow when I try to store everything
when using
On error resume next
the string where I store all the stuff breaks on the first achieved error.
If using msgBox to display - it displays everything needed though.
Somehow if I was to use this "On error resume next" I need to store a piece of text then pass it to the string so it will save before the error occurs and after as well (there are more then one error)
If u understand what I mean. Hm. I am confused myself a little.
-
August 7th, 2002, 08:36 AM
#4
post your code so we can look at it all...see what could be going wrong...because i don't understand waht you are talking about with a string being displayed but broken and then the msgbox showing everything etc...
thanks
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
-
August 8th, 2002, 01:59 AM
#5
Here's the code. ContactPropCounter is set to 0 before the loop
myContact is a contact from Outlook.
This look displays all the properties in the messageBox and stores in the string. SOmehow even when all the properties are displayed in the messageBox in the string they are stored only until the first error occurs.
_______________-----------------------
Code:
Do While ContactPropCounter < myContact.ItemProperties.count
On Error Resume Next
If myContact.ItemProperties.Item(ContactPropCounter).Value <> "" Then
MsgBox myContact.ItemProperties.Item ContactPropCounter).Name & ":::" & ContactPropCounter & "::" & myContact.ItemProperties.Item(ContactPropCounter).Type & ":" & myContact.ItemProperties.Item(ContactPropCounter).Value
contactString = contactString & myContact.ItemProperties.Item(ContactPropCounter).Name & ":" & myContact.ItemProperties.Item(ContactPropCounter).Value & ";"
End If
ContactPropCounter = ContactPropCounter + 1
Loop
-
August 8th, 2002, 03:16 AM
#6
-
August 8th, 2002, 03:42 AM
#7
Here's full code.
myContact does have itemProperties.
the error is here :
myContact.ItemProperties.Item(ContactPropCounter).Value
when there is no parameter (.value)
Another thing :
myContact.ItemProperties.Item(ContactPropCounter).Name
always works fine becuase (.name) exists with all the itemproperties
---------------
thanks for asking. Full code (all of it) :
I USE OUTLOOK MACRO (VBA)
Code:
Dim strConact As String
Dim MyOLApp As New Outlook.Application
Dim myNameSpace As NameSpace
Dim myContacts As Items
Dim myContact As ContactItem
Dim objItem As Variant
Set myNameSpace = MyOLApp.GetNamespace("MAPI")
For Each objItem In myNameSpace.GetDefaultFolder(olFolderContacts).Items
If TypeOf objItem Is Outlook.ContactItem Then
contactString = ""
userIDString = ""
Set myContact = objItem
MsgBox myContact.EntryID
Dim ContactPropCounter As Integer
ContactPropCounter = 0
userIDString = myContact.EntryID
Do While ContactPropCounter < myContact.ItemProperties.count
On Error Resume Next
If myContact.ItemProperties.Item(ContactPropCounter).Value <> "" Then
MsgBox myContact.ItemProperties.Item(ContactPropCounter).Name & ":::" & ContactPropCounter & "::" & myContact.ItemProperties.Item(ContactPropCounter).Type & ":" & myContact.ItemProperties.Item(ContactPropCounter).Value
contactString = contactString & myContact.ItemProperties.Item(ContactPropCounter).Name & ":" & myContact.ItemProperties.Item(ContactPropCounter).Value & ";"
End If
ContactPropCounter = ContactPropCounter + 1
Loop
contactString = contactString & ";"
End If
Next
'MyOLApp.Quit
Set myContacts = Nothing
Set myNameSpace = Nothing
Set MyOLApp = Nothing
-
August 8th, 2002, 04:19 AM
#8
mmmmm!!!
First:
This is not full code:
contactString
userIDString
are not declared (or you do not have the option explicit clause)
Second: tried your code in Vba (outlook 2000). Still not found the
myContact.ItemProperties
So, I guess you're using Xp.
In any case, a solution may be: if you find out some few
property itmes do not have the "value" property,
you can check for their names and skip them in the
looping cycle.
Hope this may help you
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
August 8th, 2002, 04:53 AM
#9
Yes I am using XP.
This is strage because I would want my macros to be WIn XX compatible (not only XP).
I have also found that there is a type for each itemProperty
for most of the ones without the .value, .type=0. Meaning that i can avoid most of the errors by comaring w/ .type<>0.
Thanks for the help CImperiali.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|