motash
motash

Reputation: 39

Embedded Excel COM Object clipboard interefernce

I'm writing programs in C\C++ embedding Excel and handling it's COM object. This automation process works flawlessly to manipulate sheets and getting benefit of excel capabilities.

M problem is that while processing data i use copy/paste operations, so if the processing takes some time, it's possible that interference happens as the clipboard is common between running processes

i don't know if there's a way privatize the clipboard or any other idea to avoid such problem

Thanks in advance

Upvotes: 0

Views: 330

Answers (2)

JLT
JLT

Reputation: 1

I found a way to do it for PowerShell scripts:

  • Create a Scheduled Task that call your script/program
  • Set it to "Run whether user is logged on or not"

When you run the Scheduled Task, Windows launch the script/program in a background session that uses its own Clipboard, not interfering with the one of the active session you have.

Upvotes: 0

Chris Thornton
Chris Thornton

Reputation: 15817

You cannot make a private clipboard and expect it to work with normal cut/copy/paste operations. You can use delays to avoid clipboard clashes. i.e. after you force a copy operation, wait a few hundred ms before pasting.

Also, programmatic use of the clipboard is considered bad practice. The clipboard is provided for the convenience of the user, not the programmer. See my favorite quote on the subject:

“Programs should not transfer data into our out of the clipboard without an explicit instruction from the user.” — Charles Petzold, Programming Windows 3.1, Microsoft Press, 1992

Upvotes: 1

Related Questions