문제

My application gets the string from the clipboard:

IDataObject dataInClipboard = Clipboard.GetDataObject();
string stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);

Then it manipulates the data and copies the result string to the clipboard:

Clipboard.SetText(result);

It's supposed to have a table from the Excel worksheet as the input clipboard and a string separated by [\t\r\n] as the output clipboard.

SetText() is supposed to clear the clipboard and I really have the required output clipboard. However when I manually paste it to the same Excel worksheet the previous (input) clipboard content is pasted.

Meanwhile if I previously close my application the correct output string is pasted. Moreover, if I previously finish the Excel process and then start it again the correct output is pasted as well.

Where is the bug?

도움이 되었습니까?

해결책

I noticed that the problem disappears when the application window is closed. Moreover, I decided to change the program logic: if it is supposed to work only with the Excel why not to turn it into the add-in? So, thank you guys for the assistance, the problem is solved for now.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top