View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default .NET Interop Copy all cells from Worksheet to Clipboard

If would guess it is because you are not specifying a valid range. In VBA
Dim CopyRange As Range
Set CopyRange = Worksheets(1).Cells
CopyRange.Copy Worksheets(2).Range("A1")

NickHK

"andalmeida" wrote in message
...
Hey,

Does anyone know how to copy all cell contents from a Sheet to the

clipboard?

I tried:

Excel.ApplicationClass oExcelApp;
oExcelApp = new Excel.ApplicationClass();
oExcelApp.DisplayAlerts = false;
oExcelApp.Workbooks.Open(fileName.ToString(),
System.Reflection.Missing.Value, false, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value, true,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, false, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value);

Excel.Range range = oExcelApp.Cells;
range.Select();
object dest = new object();
range.Copy(dest); <- i got a nice Exception here :-(

Thanks Dudes