Tool for Macros in MS Excel Fails when the DLP agent is installed
search cancel

Tool for Macros in MS Excel Fails when the DLP agent is installed

book

Article ID: 275237

calendar_today

Updated On:

Products

Data Loss Prevention Endpoint Prevent Data Loss Prevention

Issue/Introduction

You have a tool that runs macros (VBA script) in Excel to perform various functions, such as sending email, copy/paste, etc.
After the DLP endpoint agent is installed, the tool fails to work.

The endpoint pop-up says:

<name> email
Could not create the <name> daily email.
Microsoft Word::This method or property is not available because the Clipboard is empty or not valid.

Cause

To duplicate this issue, you need the VBA script, a blank MS Word file, and a template Excel document that contains numerical values and dates in the cells

To run the simulation, import the VBA script to MS Access as a module and run the script within MS Access.
In order for the script to work properly, verify Outlook and Excel were already launched and opened on the endpoint.
The script performed the following:

1) It takes values from the Excel sheet

2) It creates an email that contains the Excel sheet values in the body and then attaches the MS Word document to the email

When running the script, the MS Access debug displayed the following error message:

"This method or property is not available because the Clipboard is empty or not valid.

0

Microsoft Word"

We observed that the issue occurred only the first time when the system started.
It worked on the subsequent test attempts. 
By looking at this behavior this seems like a timing issue. 

We are also able to reproduce the issue without DLP - but with a lower frequency of occurrence.
That is, we encountered the issue one time after around 5-6 attempts. 
This confirms that it is a timing issue. 

Resolution

With DLP, the frequency of hitting this issue increases and it is more likely to occur since DLP has its processing on content to perform detection to avoid data leaks. 

We suggest that the script includes a 'sleep' and call to the "DoEvents" API. 

The sleep function may not totally resolve the issue.
However, adding the "DoEvents" API to the script has resolved this issue.