[python-win32] How to access Visual Basic's "Application" obj ect, in Python

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Jan 27 09:53:19 CET 2005


[Tony Cappellini]
| 
| I am trying to mimic a short VB program in Python, which 
| iterates over an
| Outlook 2002 global address list.
| 
| However, I don't know what to use  in Python, for VB's 
| Application object, which is like a pointer to the entire 
| process that is running the application. From Application, 
| I can access the name of the executable,
| the version number, tha path, and some other attibutes.

I admit I hadn't heard of the Application object as
something outside Outlook. Care to give an example of
these extra attributes. At the risk of stating the obvious,
the code below seems to reproduce what your own code
is doing. (But maybe you knew that).

<code>

import win32com.client

outlook = win32com.client.gencache.EnsureDispatch ("Outlook.Application")

#
# Assume you've got an Outlook session running,
#  so don't bother specifying a profile.
#
outlook.Session.Logon ()

namespace = outlook.GetNamespace ("MAPI")
global_address_list = namespace.AddressLists["Global Address List"]
address_entries = global_address_list.AddressEntries["!IT Development"]

print address_entries.Members.Count
for i in range (address_entries.Members.Count):
  member = address_entries.Members[i + 1]
  print member.Name, member.Address

</code>

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the Python-win32 mailing list