views:

55

answers:

4

Hi,

I am copying the contents of an Excel file onto the Clipboard within a program I have written. I can then use that data in memory rather than 'chatting' constantly with Excel.

When I have finished with the data, I cal a cleanup method that calls Clipboard.Clear() first and then closes all Excel sheets/workbooks/apps, etc.

The problem is, even though I clear the Clipboard prior to closing the Excel sheets, I get a pop up window still saying there is substantial amount of data on the clipboard. Anybody know why?

Thanks,

Darren.

+1  A: 

Not sure why that happens, but have you tried setting _Application.DisplayAlerts = false; (MSDN) before you close the sheets to see if that prevents the warning message?

Zach Johnson
Thanks, works like a charm
darren young
A: 

You could try setting the Excel CutCopyMode property to cancel the current copy information:

Application.CutCopyMode = false;

Another thought is to set the clipboard to String.Empty so the amount of data copied is small enough that it bypasses the warning popup. This may have to be done from the Excel sheet, not the regular clipboard (i.e., copy a cell from the active sheet in Excel).

Ahmad Mageed
A: 

Perhaps you could use

Application.CutCopyMode = false;

http://msdn.microsoft.com/en-us/library/ff839532.aspx

kaze
Application.DisplayAlerts = false, works perfectly. Thanks for all the responses.
darren young
A: 

Well at the end, try copying an empty string in clipboard and leave it, then Excel may not give any warning. But use Excel API to copy empty string in clipboard.

Akash Kava