Why doesn't this work?!! 
Author Message
 Why doesn't this work?!!

Hi all!

I have made Outlook VBA code which loops through all items in a folder. In
this folder it is both contact items and post items.

Why do I get this Type Mismatch error when the code reach the row:
strTjanst = objTjanst.UserProperties("Tj?nst") ?

Maybe this is something easy, but I can't find it....

-------------Code  start------------------
    Dim appOutlook As Outlook.Application
    Dim fld As MAPIFolder
    Dim objTjanst As Object
    Dim strTjanst As String

    Set appOutlook = CreateObject("Outlook.Application")
    Set fld = appOutlook.ActiveExplorer.CurrentFolder

    For Each objTjanst In fld.Items
        Debug.Print objTjanst.Subject
        If objTjanst.Class = olPost Then
            strTjanst = objTjanst.UserProperties("Tj?nst")
            strForetag = objTjanst.Subject
         End If
    Next
 -------------Code  end------------------

    Thanx in Advance

    Ulrik Gustafsson



Sat, 14 Feb 2004 16:52:21 GMT  
 Why doesn't this work?!!
It sounds like the field was not added to the folder/item
as a text data type. You could work around this...

strTjanst = CStr(objTjanst.UserProperties("Tj?nst").Value)

Steve Mazzola, MCSD

Quote:
>-----Original Message-----
>Hi all!

>I have made Outlook VBA code which loops through all

items in a folder. In
Quote:
>this folder it is both contact items and post items.

>Why do I get this Type Mismatch error when the code reach
the row:
>strTjanst = objTjanst.UserProperties("Tj?nst") ?

>Maybe this is something easy, but I can't find it....

>-------------Code  start------------------
>    Dim appOutlook As Outlook.Application
>    Dim fld As MAPIFolder
>    Dim objTjanst As Object
>    Dim strTjanst As String

>    Set appOutlook = CreateObject("Outlook.Application")
>    Set fld = appOutlook.ActiveExplorer.CurrentFolder

>    For Each objTjanst In fld.Items
>        Debug.Print objTjanst.Subject
>        If objTjanst.Class = olPost Then
>            strTjanst = objTjanst.UserProperties("Tj?nst")
>            strForetag = objTjanst.Subject
>         End If
>    Next
> -------------Code  end------------------

>    Thanx in Advance

>    Ulrik Gustafsson

>.



Sat, 14 Feb 2004 18:02:42 GMT  
 Why doesn't this work?!!
Unfortunately it still doesn't work.

I have also tried to run this code on a folder with one single item (a
postitem)

I still get this TypeMismatch Message. If I modify the code and try with a
contactitem it works.
Ulrik


It sounds like the field was not added to the folder/item
as a text data type. You could work around this...

strTjanst = CStr(objTjanst.UserProperties("Tj?nst").Value)

Steve Mazzola, MCSD

Quote:
>-----Original Message-----
>Hi all!

>I have made Outlook VBA code which loops through all

items in a folder. In
Quote:
>this folder it is both contact items and post items.

>Why do I get this Type Mismatch error when the code reach
the row:
>strTjanst = objTjanst.UserProperties("Tj?nst") ?

>Maybe this is something easy, but I can't find it....

>-------------Code  start------------------
>    Dim appOutlook As Outlook.Application
>    Dim fld As MAPIFolder
>    Dim objTjanst As Object
>    Dim strTjanst As String

>    Set appOutlook = CreateObject("Outlook.Application")
>    Set fld = appOutlook.ActiveExplorer.CurrentFolder

>    For Each objTjanst In fld.Items
>        Debug.Print objTjanst.Subject
>        If objTjanst.Class = olPost Then
>            strTjanst = objTjanst.UserProperties("Tj?nst")
>            strForetag = objTjanst.Subject
>         End If
>    Next
> -------------Code  end------------------

>    Thanx in Advance

>    Ulrik Gustafsson

>.



Sat, 14 Feb 2004 22:03:08 GMT  
 Why doesn't this work?!!
Is the Tj?nst field defined as a text data type in your
custom Post Item?

Steve

Quote:
>-----Original Message-----
>Unfortunately it still doesn't work.

>I have also tried to run this code on a folder with one
single item (a
>postitem)

>I still get this TypeMismatch Message. If I modify the
code and try with a
>contactitem it works.
>Ulrik



>It sounds like the field was not added to the folder/item
>as a text data type. You could work around this...

>strTjanst = CStr(objTjanst.UserProperties("Tj?nst").Value)

>Steve Mazzola, MCSD

>>-----Original Message-----
>>Hi all!

>>I have made Outlook VBA code which loops through all
>items in a folder. In
>>this folder it is both contact items and post items.

>>Why do I get this Type Mismatch error when the code reach
>the row:
>>strTjanst = objTjanst.UserProperties("Tj?nst") ?

>>Maybe this is something easy, but I can't find it....

>>-------------Code  start------------------
>>    Dim appOutlook As Outlook.Application
>>    Dim fld As MAPIFolder
>>    Dim objTjanst As Object
>>    Dim strTjanst As String

>>    Set appOutlook = CreateObject("Outlook.Application")
>>    Set fld = appOutlook.ActiveExplorer.CurrentFolder

>>    For Each objTjanst In fld.Items
>>        Debug.Print objTjanst.Subject
>>        If objTjanst.Class = olPost Then
>>            strTjanst = objTjanst.UserProperties
("Tj?nst")
>>            strForetag = objTjanst.Subject
>>         End If
>>    Next
>> -------------Code  end------------------

>>    Thanx in Advance

>>    Ulrik Gustafsson

>>.

>.



Sun, 15 Feb 2004 09:19:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Why oh why doesn't this work?

2. Why doesn't this work?

3. Why doesn't this work???

4. Why doesn't this work?

5. why doesn't it work?????

6. Why doesn't this work?

7. Why doesn't this work anymore?

8. threading and why doesn't it work!!!! :)

9. Itemop.Navigate - Why doesn't it work?!

10. Why doesn't this work

11. Why doesn't it work?

12. Help needed !! Why doesn't this work

 

 
Powered by phpBB® Forum Software