Posted by: quim on 8 September 2017, 3:05 pm EST

  • Posted 8 September 2017, 3:05 pm EST



    I'm copying a range of cells in order to paste all the cell formats to new cells that are inserted in a loop.

    The code is executed always in the same way (it's a report that is build always with same data). The problem is that sometimes I get this error when using "ClipboardCopy":

    <b> "Requested Clipboard operation did not succeed" </b>


    this is the code I'm using


    with sp1.sheets(0)

                    .AddSelection(row1, col1, 1, last_col - col1 + 1)

                    crange = fp.ActiveSheet.GetSelection(0)

                    .ClipboardCopy(crange, Spread.ClipboardCopyOptions.All)


                    While rd.Read


                           .SetActiveCell(r, col1)


                     end While

    end with


    Should I create a kind of loop to wait and retry several times?



  • Replied 8 September 2017, 3:05 pm EST


    There is no such issue reported in the past or any known issue related to ClipboardCopy, so it would be difficult to comment on the issue without replicating the same at my end. I would request you to provide a sample application depicting your issue so that I can replicate the issue at my end and debug it further.

    However there are several links that suggest to try the copy paste operation several times to resolve the issue, here are a few links:



    You may try implementing the same. Hope it helps.


    Manpreet Kaur

  • Replied 8 September 2017, 3:05 pm EST


     This makes all the sense, but it's also a problem because if the application makes a copy to clipboard and is doing a paste inside a loop the clipboard content may change during the loop if any other application uses the clipboard.

    It's the same as using a global memory variable that can be written by any windows application.

    Do I have any other way to copy the formats of a specific cell range where I don't know what to expect (may be different borders, fonts names or sizes, alignment, background and foreground color, cell types, etc) and apply those formats to a new range of cells?



  • Replied 8 September 2017, 3:05 pm EST


    There seems to be no other way to copy paste the formatting of a cell range. You would need to use the copy paste operations i.e the ClipboardCopy and ClipboardPaste methods to accomplish the same.


    Manpreet  Kaur

  • Marked as Answer

    Replied 29 September 2017, 12:57 pm EST

    Hi quim,

    Try this code, I just have same problem and fixed. You can refer to another thread was talking about this error message and may have help.

    DataObject o = new DataObject();
    o = sdPrint.GetClipDataObject(false, new CellRange(0, 0, 5, 5), ClipboardCopyOptions.All);
    sdPrint.SetActiveCell(20, 10);
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels