Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Macro freezes Outlook

I have this rather heavy Excel macro. When it runs Outlook freezes.

I know it is not using all the CPU power because
a) I have a powerful multiple-core machine
b) all my other programs (even heavy-duty ones) are running fine.

It seems like Outlook and Excel are sharing a process that Excel is hogging.

My macro does nothing Outlook-related, at least not knowingly. It pulls data from Bloomberg and does some calculation.

like image 873
RAY Avatar asked Sep 06 '25 12:09

RAY


2 Answers

I appreciate the horse has very much left the corral...however, I too have experienced this and with no references in my code to the Outlook model. I've also noticed my Excel locking up whilst macros in another Excel instance are running.

To resolve this you need add a

DOEVENTS

line to your code, to quote the MSDN site

DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue

Where to put the DOEVENTS line very much depends on your code, but in a rather heavy macro of mine where I make a number of SQL calls, I've placed it just before each SQL call which appears to work well. Allowing me to work quite happily in one Excel instance whilst the background instance does a number of SQL fetches.

like image 145
David Ackroyd Avatar answered Sep 09 '25 23:09

David Ackroyd


The same thing happened to me when migrating my macros to Office 2016. The solution: uncheck the library "Microsoft Office 16.0 Object Library", which is included by default when you create a new vba module.

like image 27
Lyon Avatar answered Sep 09 '25 22:09

Lyon