LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview calling MS Excel Macros: "We couldn't free up space on the Clipboard. Another program might be using it right now."

Hello,

 

I am running into an issue when calling Excel macros with Labview. Some background:

 

Software:

LabVIEW 2018 32-bit

MS Excel 2013 32-bit

 

I have an Excel workbook that contains several macros written in "Excel 4.0 Macro". These macros involve copy and pasting sets of data numerous times. (Please see following code snippet for an example. The actual macros contain a lot more copy and paste statements and moves the data throughout different worksheets.)

 

 

Excel 4.0 Macro Example
MacroA(a)
=ACTIVATE("ExcelWorkbook.xls")
=WORKBOOK.SELECT("SHEET1","SHEET1")
=FORMULA.GOTO("RANGE")
=COPY()
=WORKBOOK.SELECT("SHEET2","SHEET2")
=FORMULA.GOTO("RANGE")
=PASTE.SPECIAL(3,1,FALSE,FALSE)
=RETURN()

 

 

 

These are currently run by an operator using keyboard shortcuts. The goal is to automate the running of the macros with Labview using Microsoft Excel 15.0 Object Library Version 1.8.

 

I am not sure how to use Labview to call the "Excel 4.0 Macro" macros directly. So I wrote a VBScript file in the workbook with functions that call the "Excel 4.0 Macro" macros.

 

 

VBScript Function Example:
Sub Run_Macro_4.0()
     Application.Run ("MacroName")
End Sub

 

 

Labview will call the VBScript functions to run the "Excel 4.0 Macro" macros.

 

This all works fine, except I get the following dialogue when running the macros through Labview:

Excel Clipboard Dialogue.PNG

"We couldn't free up space on the Clipboard. Another program might be using it right now"

 

The dialogue pops up intermittently. I ran one particular macro several times through Labview. Sometimes I get the dialogue pop up a few times during one call, sometimes not at all. The pop ups are not acceptable as the system needs to be automated without the need for an operator.

 

Has anyone else experienced a problem similar to this? If so, is there anyway to just bypass the dialogue?

 

I will end with a screenshot of my block diagram for my simple Run Macro with Labview utility.

 

Run Excel Macro Snippet.PNG

 

Thanks for your time

Gabe

Download All
0 Kudos
Message 1 of 7
(3,128 Views)

Hi Gabe,

Could you include a command to clear the clipboard at the end of every macro?

Maybe something like:

 

Application.CutCopyMode = False

 

This may break the clipboard reference that Excel is holding onto.

0 Kudos
Message 2 of 7
(3,109 Views)

csIowa,

 

Ah, just tried this approach but still get the pop up. I see the dialogue in the middle of a macro run so I guess clearing at the end doesn't help.

 

Sub Run_Macro_4.0()
     Application.Run ("MacroName")
     Application.CutCopyMode = False
End Sub

 

I also tried clearing the clipboard before a macro run. Still get the pop up.

 

Sub Run_Macro_4.0()
     Application.CutCopyMode = False
     Application.Run ("MacroName")
     Application.CutCopyMode = False
End Sub

 

Gabe

0 Kudos
Message 3 of 7
(3,101 Views)

Have you tried the solutions posted here?

 

https://answers.microsoft.com/en-us/msoffice/forum/all/excel-2016-error-we-couldnt-free-up-space-on-...

 

What other applications do you have open while running these programs?  Is there a specific application open when the dialog does come up?

0 Kudos
Message 4 of 7
(3,097 Views)

From LabVIEW you are calling a VB script to run an Excel macro. I would try adding delays between the copy/paste iterations.

 

Ben64

Message 5 of 7
(3,082 Views)

RMowatt,

 

My program was installed on a bare Win10 PC. Only apps installed are LabVIEW and its drivers, MS Office 2013, and Notepad++. No other apps were open when macro runs. Just standard background Win10 processes.

 

Ran sfc /scannow, disabled addons, and rebooted as suggested. No luck.

 

I will try other solutions but my last resort will be to execute each process not required for Windows to try to find a conflicting application.

 

==================

 

Ben64,

 

I will try to add a delay between copy and paste iterations. Be back shortly.

 

Thanks

Gabe

0 Kudos
Message 6 of 7
(3,003 Views)

Ben64,

 

Great suggestion. I added a 2 second wait between copy and paste iterations. I did not get the dialogue after running the macro ~10 times. I did get a different dialogue stating "Cannot open clipboard" but it only happened once.

 

So macro is much more stable. Just need to verify integrity of data.

 

Looks like the problem was actually happening in the "Excel 4.0 Macro" level and not VB and Labview calling it. Even though functions are called sequentially, clipboard falls behind?

 

For now I will implement the delay in all the macros and do more intensive testing.

 

Thanks,
Gabe

0 Kudos
Message 7 of 7
(2,994 Views)