I need to copy up to 21 specific columns from a large worksheet (advstringgrid; ASG1) to a second worksheet (ASG3). Below is my code. I select an ASG1 column, copy it to the clipboard, go to Row 1 of the next ASG3 column, and paste from the clipboard.
I frequently get a 'Cannot open clipboard. Access denied' error. Is there a better approach? Any ideas for fixing?
{ Copy selected col from ASG1 to ASG3...}
Col_ASG2 := 0;
for i:=1 to 21 do begin
if SaveColArray<>-1 then begin
Col_ASG1 := SaveColArray; // get ASG1 column number
ASG1.SelectRange(Col_ASG1,Col_ASG1,1,ASG1.RowCount-1); // select the ASG1 column
ASG1.CopySelectionToClipboard; // copy to Clipboard
INC(Col_ASG2); // next ASG2 column
ASG3.GotoCell(Col_ASG2,1); // go Row 1 of the next ASG2 column
ASG3.PasteSelectionFromClipboard; // paste from the Clipboard
strlist.Add(SaveColNameArray); // Add col working title
end;
end;