Display Outlook contacts 
Author Message
 Display Outlook contacts

I get an error on the line:
Next myItem  <Char: 6,  Expected end of statement>
Anyone have an idea of my problem?
Thanks!
=================================================

Call ReadOtlContacts

Function ReadOtlContacts

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

Set myItems = myFolder.Items
myItems.Sort "[CompanyName]", False
For Each myItem in myItems
    MsgBox myItem.CompanyName
Next myItem

End Function



Sun, 11 May 2003 03:00:00 GMT  
 Display Outlook contacts
remove the 'myItem' and it should run fine.

it should look like this:

For Each myItem in myItems
    MsgBox myItem.CompanyName
Next


Quote:
> I get an error on the line:
> Next myItem  <Char: 6,  Expected end of statement>
> Anyone have an idea of my problem?
> Thanks!
> =================================================

> Call ReadOtlContacts

> Function ReadOtlContacts

> Set myOlApp = CreateObject("Outlook.Application")
> Set myNamespace = myOlApp.GetNamespace("MAPI")
> Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

> Set myItems = myFolder.Items
> myItems.Sort "[CompanyName]", False
> For Each myItem in myItems
>     MsgBox myItem.CompanyName
> Next myItem

> End Function



Sun, 11 May 2003 03:00:00 GMT  
 Display Outlook contacts
Jay,
I thought the same and tried without it before writing my first post.  I
just included it because the lengendary Michael Harris had it there..  But,
yea, it has the same error without the myItem except that it is Char: 1 that
gets the error.


Quote:
> remove the 'myItem' and it should run fine.

> it should look like this:

> For Each myItem in myItems
>     MsgBox myItem.CompanyName
> Next



> > I get an error on the line:
> > Next myItem  <Char: 6,  Expected end of statement>
> > Anyone have an idea of my problem?
> > Thanks!
> > =================================================

> > Call ReadOtlContacts

> > Function ReadOtlContacts

> > Set myOlApp = CreateObject("Outlook.Application")
> > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

> > Set myItems = myFolder.Items
> > myItems.Sort "[CompanyName]", False
> > For Each myItem in myItems
> >     MsgBox myItem.CompanyName
> > Next myItem

> > End Function



Fri, 16 May 2003 03:00:00 GMT  
 Display Outlook contacts
Had what where???

I don't recall ever knowingly posting

For Each foo In AWholeBunchOfFoos
    ...
Next Foo <=== this is what Jay is referring to...

unless I happened to copy/paste a ***VBA*** example from the Outlook 2000 documentation (where it is
legal ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--


Quote:
> Jay,
> I thought the same and tried without it before writing my first post.  I
> just included it because the lengendary Michael Harris had it there..  But,
> yea, it has the same error without the myItem except that it is Char: 1 that
> gets the error.



> > remove the 'myItem' and it should run fine.

> > it should look like this:

> > For Each myItem in myItems
> >     MsgBox myItem.CompanyName
> > Next



> > > I get an error on the line:
> > > Next myItem  <Char: 6,  Expected end of statement>
> > > Anyone have an idea of my problem?
> > > Thanks!
> > > =================================================

> > > Call ReadOtlContacts

> > > Function ReadOtlContacts

> > > Set myOlApp = CreateObject("Outlook.Application")
> > > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > > Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

> > > Set myItems = myFolder.Items
> > > myItems.Sort "[CompanyName]", False
> > > For Each myItem in myItems
> > >     MsgBox myItem.CompanyName
> > > Next myItem

> > > End Function



Fri, 16 May 2003 03:00:00 GMT  
 Display Outlook contacts
yeah, I think it probably was a VBA ex.....  I'm still 'fused and seeking,
so I've re-posted as 'Loop through Items collection'
BTW, thanks for all your insightful posts.  I have a "VBScript - MHarris"
folder now.   : - )


Quote:
> Had what where???

> I don't recall ever knowingly posting

> For Each foo In AWholeBunchOfFoos
>     ...
> Next Foo <=== this is what Jay is referring to...

> unless I happened to copy/paste a ***VBA*** example from the Outlook 2000

documentation (where it is
Quote:
> legal ;-)...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup...
> --



> > Jay,
> > I thought the same and tried without it before writing my first post.  I
> > just included it because the lengendary Michael Harris had it there..
But,
> > yea, it has the same error without the myItem except that it is Char: 1
that
> > gets the error.



> > > remove the 'myItem' and it should run fine.

> > > it should look like this:

> > > For Each myItem in myItems
> > >     MsgBox myItem.CompanyName
> > > Next



> > > > I get an error on the line:
> > > > Next myItem  <Char: 6,  Expected end of statement>
> > > > Anyone have an idea of my problem?
> > > > Thanks!
> > > > =================================================

> > > > Call ReadOtlContacts

> > > > Function ReadOtlContacts

> > > > Set myOlApp = CreateObject("Outlook.Application")
> > > > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > > > Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)

> > > > Set myItems = myFolder.Items
> > > > myItems.Sort "[CompanyName]", False
> > > > For Each myItem in myItems
> > > >     MsgBox myItem.CompanyName
> > > > Next myItem

> > > > End Function



Sat, 17 May 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Displaying Outlook Contact list from Web page

2. Customize default outlook Contacts View to display Images in the view

3. Creating a MS Outlook style Contact display???

4. Creating a MS Outlook style Contact display???

5. VBA Display selected contacts/people from a Shared contact list

6. best way to sync Outlook contacts with a SQL Server contacts database

7. Find a contact in Outlook contact or in a access database

8. VB send outlook contact to contacts subfolder?

9. Prob : Adding contacts for Outlook 2000 and Outlook 97

10. How to create a contact item in Outlook fra a webform

11. Pocket Outlook - Delete all contacts belonging to a category

12. Help Help needed Opening Outlook Contacts(public) in VB5

 

 
Powered by phpBB® Forum Software