Automatically trigger a VBA macro to run when connection to exchange server has been made.

M

matt

I am currently producing a very simple electronic in/out board for my
company. It works by using a public folder to which are posted the
names of everyone in a particular office. For each user you can select
whether you are in or out, where you are and when you are likely to
return.

I have written a number of VBA macros which can be run by the users to
update their status, the system also automatically marks them as out
when Outlook is closed.

I would like to call the "sign in" macro to run automatically when
outlook starts up, but as there is a delay between outlook starting and
finally connecting to our exchange server (very tempermental
connection) I need to call the sign in macro when the connection has
been established.

Does anyone know how I could call this macro to run at the right time?
 
G

Guest

I've struggled with the best way to approach doing a startup task with
Exchange before and had to ping fellow MVP Ken Slovak to jog my memory; see
what he says below. If you don't want to run your code on
Application_Startup, consider hooking into the SyncStart event for any of the
SyncObjects that are available for each Send/Receive group, even if none of
them are Exchange-specific. These calls should at least give you some
seconds after startup to hope that an Exchange connection could be made in
the interim.

I would check a combination of NameSpace.ExchangeConnectionMode,
NameSpace.Offline (PR_STORE_OFFLINE for earlier than Outlook 2002)
and PR_REPLICA_VERSION (Exchange version, 0.0.0.0 for offline or
cached mode). That covers combinations of Outlook and Exchange
versions pretty well.

The old CDO way of putting PR_REPLICA_VERSION (PT_I8) into a string
for CDO 1.21 from the KB doesn't work when using Redemption. See
http://www.slovaktech.com/code_samples.htm#ExchangeVersion for a
Redemption version of the KB code.

Also, when retrieving PR_REPLICA_VERSION for Exchange 2000 and 2003
you get "6.5.xxxx.xxxx" for both. So you have to look at the minor
and build fields to see which version of Exchange.

http://support.microsoft.com/default.aspx?scid=kb;en-us;158530 lists
the versions, so you can use that to figure out EX2003 or EX2000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top