Sometimes, we might need to manipulate a bunch of RTF or PDF files using Excel VBA. As number of RTF or PDF files to be combined goes larger, the chance of emerging warning message becomes larger. One of the common warning message is “Microsoft Excel is waiting for another application to complete an OLE action”.
What is OLE
OLE is Object Linking and Embedding (OLE) action which is a technology allowing office apps to interact with other apps. It allows an editing app (Microsoft Excel in our case) to send part of a document (filename of Word document, for example) to other apps (e.g. Microsoft Word) and then it takes back information from other apps (Microsoft Word) to current editing app (Microsoft Excel).
Reasons for the occurrence of “Microsoft Excel is waiting for another application to complete an OLE action”
Here are there common reasons which can result into the occurrence of above warning message.
- Adding too many add-ins to the Excel application and one or more of these add-ins are corrupt
- Excel tries to open a file created in another other application like Microsoft Word or extract data from an active application
- Send an Excel sheet using “Send as Attachment” option of Excel in an email
And in our case, it is because that the required response does not come fast enough. For example, when errors occurs when opening a word document, Excel will absolutely send such warning message.
How to turn off “Microsoft Excel is waiting for another application to complete an OLE action” in VBA
There are a lot of posts describing how to disable this warning message by disabling add-ins or enabling the “Ignore other application that use DDE” feature. However, these approaches do not help when coming to creating a tool using VBA. Here is how to turn off it by declaring a function. If your compute is 64-bit system, please use PtrSafe attribute.
If you do not add PtrSafe attribute on 64-bit system, Excel will display a Compile error like below.