> Yes. "it" is the executable. Specifically, when checking "If TypeOf
then Re-add the reference to Outlook. I suspect because you took the
internal app and you can control the version of Outlook deployed. If your
"Rooney" <Rmerchant@martinmartin.com> wrote in message
news:OXSUKYf1DHA.2700@TK2MSFTNGP11.phx.gbl...
> Jay,
> Yes. "it" is the executable. Specifically, when checking "If TypeOf
> Contact Is Outlook.ContactItem Then" to see if the TypeOf item is a
> Outlook.ContactItem. Looking at "Contact" in the debugger window, it
tells
> me that "Contact" is of type "{System.__ComObject}". The "If" check then
> fails and simply moves on to the next item in myContacts. Here is the
code.
>
> Dim myOlApp As New Outlook.Application
> Dim myNameSpace As Outlook.NameSpace
> Dim myContacts As Object
> Dim Contact As Object
> Dim Contacts As Outlook.ContactItem
> Dim fldFolder As Outlook.MAPIFolder
> Dim i As Short
> Dim SearchLen As Short
>
> myOlApp = New Outlook.Application
> myNameSpace = myOlApp.GetNamespace("MAPI")
> fldFolder =
> myNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
> myContacts = fldFolder.Items
> SearchLen = Len(txtSearchName.Text)
> On Error GoTo SearchError
> If optLastName.Checked = True Then
> i = 1
> myContacts.Sort("[lastname]", 6)
> 'Cylcle through the records and store contacts matching search text
> For Each Contact In myContacts
> If TypeOf Contact Is Outlook.ContactItem Then ' *** Here is
the
> line I'm referring to ***
> Contacts = DirectCast(Contact, Outlook.ContactItem)
> If UCase(VB.Left(Contacts.LastName, SearchLen)) =
> UCase(txtSearchName.Text) Then
> FirstNameStore(i) = Contacts.FirstName
> LastNameStore(i) = Contacts.LastName
> CompanyStore(i) = Contacts.CompanyName
> AddressStore(i) = Contacts.BusinessAddressStreet
> CityStore(i) = Contacts.BusinessAddressCity
> StateStore(i) = Contacts.BusinessAddressState
> ZipStore(i) = Contacts.BusinessAddressPostalCode
> PhoneStore(i) = Contacts.BusinessTelephoneNumber
> FaxStore(i) = Contacts.BusinessFaxNumber
> i = i + 1
> End If
> End If
> Next Contact
> End If
>
> I am using Office XP on my home machine (where the code runs fine) and
Offic
> e 2000 SR-1 on my office (networked) machine. I have included a reference
> to Interop.Outlook so that may be my problem. I'm using the same version
of
> VS.NET on both. I have created a setup package and the installation runs
> fine but right now I'm just running it inside VS.NET. Is there a way to
> restructure the code to work with both versions? I tried following the
> instructions on "Rebuilding the Outlook Interop Assembly" in the link you
> sent me, but the "access privileges" alerady appear to be Public. You're
> dealing with a complete novice and I'll be honest, that didn't make much
> sense to me and I'm not very familiar with the PIA. Our office is
planning
> to upgrade to Office XP but it hasen't happened yet.
>
> Any insight would be helpful. Thanks.
>
> Rodd
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
> news:uVkQy5X1DHA.1700@TK2MSFTNGP12.phx.gbl...
> > Rooney,
> > What is "it". Just the executable? Did you include the PIA if you are
> using
> > the PIA, did you include the generated interop if you are using that?
> >
> > Is your network machine have the same version of Outlook and VS.NET?
Does
> it
> > have or not have the same PIA installed?
> >
> > Generally when using interop, I would highly recommend creating a setup
> > package to ensure that things are installed correctly, also if possible
I
> > would highly recommend using the PIA, however this limits you on Outlook
> > versions...
> >
> > If I did not include it, the following site includes a number of
articles
> on
> > using Outlook with .NET:
> >
> >
http://www.microeye.com/resources/res_outlookvsnet.htm > >
> > Hope this helps
> > Jay
> >
> > "Rooney" <Rmerchant@martinmartin.com> wrote in message
> > news:%23R1Ei8S1DHA.2480@TK2MSFTNGP10.phx.gbl...
> > > Jay,
> > >
> > > The solution you sent worked fine on my non-networked machine but when
I
> > > moved it to my netowork machine I get something unexpected when
checking
> > to
> > > see if the TypeOf item is Outlook.ContactItem.
> > >
> > > The debugger tells me that the item is of type "{System.__ComObject}".
> It
> > > then fails the check to see if it is a ContactItem and just moves on
to
> > the
> > > next item.
> > >
> > > Any thoughts?
> > >
> > > Rodd
> > >
> > > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in
> message
> > > news:%23Q%23mzOI0DHA.1272@TK2MSFTNGP12.phx.gbl...
> > > > Rooneyh,
> > > > I normally use an "Object" variable for the For Each, then use
TypeOf
> to
> > > > check the object for the specific type.
> > > >
> > > > Something like:
> > > >
> > > > Dim Contact As Outlook.ContactItem
> > > > Dim DistList As Outlook.DistListItem
> > > >