Outlook and VB6

  • Thread starter Thread starter Bryan Dickerson
  • Start date Start date
B

Bryan Dickerson

I don't know if this falls into the topic of this ng, but I didn't see
another one that this fit in, so here goes. Also this may not actually be a
code problem, but an Outlook/networking problem on this user's box--I just
need more evidence to present to my network admins before they will believe
me.

I have a routine that reads a VB routine that reads an Outlook Address List
and has worked for a long time, but for some reason on this one user's box,
the routine is not seeing the entries in the Address List--it sees 0
entries. The Address list can be viewed from his machine by creating an
email and looking at the address book, so I know it's there. And other
users are able to get run the routine fine.

Any ideas on what to look for??

Thanks for any help in advance!

Bryan
 
This is the correct group but we'd need more information. What version of
Outlook, Exchange or not, if Exchange what version? How is this user's setup
different than other users setups, if at all?

Also, show the code you're using.
 
We have Exchange 2000 Enterprise and the user who is having a problem is
using Outlook 2003 client. There are other Outlook 2003 clients who are not
having a problem and I have Outlook XP SP3 and I don't have a problem
running the routine.

The following is my code:
================================================
Dim sNames() As String
Dim i As Integer
Dim oOL As Outlook.Application
Dim oNS As NameSpace
Dim oALsts As Redemption.AddressLists
Dim oAList As Redemption.AddressList

Set oOL = New Outlook.Application
Set oNS = oOL.GetNamespace("MAPI")
Set oALsts = New Redemption.AddressLists
Set oAList = oALsts.Item("Executives")

With oAList.AddressEntries
If CBool(.Count) Then
ReDim sNames(.Count - 1)
For i = 1 To .Count
sNames(i - 1) = .Item(i).Name
Next
End If
End With
mvarNames = Join(sNames, ";")

Set oOL = Nothing
Set oNS = Nothing
Set oAList = Nothing
================================================
 
And where is the code running?

I'd expect problems using New. I'd use CreateObject instead both for the
Outlook.Application object and for the Redemption object. I'd also not use
CreateObject at all if the code is running in a COM addin or Outlook VBA for
the Outlook.Appliction object, use the intrinsic Application object passed
to you in the COM addin's On_Connection event handler or the intrinsic
Application object in Outlook VBA.

I'd also make sure I have the latest version of Redemption, and I'd set
oALsts to be explicitly Application.AddressLists.
 
The code is running in a VB6 com object. That's why I said that I was not
sure if this fit the NG topic. I do have the latest version of Redemption.
 
In a COM addin never instantiate your own Application object, especially
with Outlook 2003. Just use the Application object passed in On_Connection
and derive all your Outlook objects, including any Outlook.Application
objects from that. And don't use New.




Bryan Dickerson said:
The code is running in a VB6 com object. That's why I said that I was not
sure if this fit the NG topic. I do have the latest version of
Redemption.
 
Beyond that, this same code is running under OL 2003 on a bunch of other
machines as I presented it. So maybe that's it: it's not a programming
issue. The problem there is that I don't know OL well enough to know what
to look for that changed. It's worse than a needle in a haystack.
 
Well, the tips I gave you are good programming practice in any case and some
systems are more sensitive than others. For example, if the user is running
a script stopper from Norton then using New or CreateObject to get an
Outlook application object will crash Outlook. So that's a case where the
same Outlook version and OS can behave differently depending on other
software that's installed.

I'd implement the tips in any case, they will save you trouble in the long
run even if they don't solve this particular problem.
 
Back
Top