How to run a macro in the background?

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I've written a macro for Outlook (Office XP) that moves
messages from Inbox folders to various .PST files. When it
runs, it seems to be interacting continuously with the
desktop, i.e., the cursor changes shape constantly, the
Outlook window moves to and from the background (title bar
turns grey, back to blue), etc. If another task is started
in the foreground, it loses control of the desktop
constantly until the macro finishes. Is there a setting
that would cause the macro to run "silently"?
 
Outlook macros all run in-process with Outlook so there is no such
thing as macro background processing. The only thing is to not do
other things until your macro completes and to try to write your macro
so it runs as quickly as possible.
 
Ken, thanks for the reply. Has this always been the case?
I don't recall that macros ran in-process in earlier
versions of Outlook, at least, I don't recall the behavior
of changing the cursor, etc., like interacting with the
desktop. Actually, the bigger problem is that while the
macro is running in-process with Outlook, Outlook always
asserts itself to the foreground. Is there a way to keep
Outlook silent while minimized or while another window is
in the foreground? TIA...
 
Macros in Outlook are only available in Outlook 2000 or later and
always have run in-process with the Outlook application. The only way
I know to avoid the problem is to not show Outlook, which can be done
if you start Outlook using automation code but you obviously can't do
that in a macro.

You might just want to look into various ways of optimizing your
application, using things such as With...End With, For Each instead of
For i = 1 To etc., using SetColumns and Items collection restrictions
and so on. Also, for iterating collections using CDO 1.21 code is an
order of magnitude faster than Outlook object model code if you can
use CDO for what you want and it doesn't fire the security prompts for
what you are doing.
 
Back
Top