Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default .NET Interop Copy all cells from Worksheet to Clipboard

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default .NET Interop Copy all cells from Worksheet to Clipboard

thanks, so i tried, but failed:

Excel.Range range = oExcelApp.Cells;
range.Copy("A1");

and got same exception:
"Copy method of Range class failed"
" at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)\r\n at Excel.Range.Copy(Object Destination)\r\n at
xlsconcat.Form1.button2_Click(Object sender, EventArgs e) in
C:\\Anderson\\xlsconcat\\Form1.cs:line 53\r\n at
System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)\r\n at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32
clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at
System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n at
System.Windows.Forms.Button.WndProc(Message& m)\r\n at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)\r\n
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)\r\n
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)\r\n at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)\r\n at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)\r\n at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)\r\n at
System.Windows.Forms.Application.Run(Form mainForm)\r\n at
xlsconcat.Program.Main() in C:\\Anderson\\xlsconcat\\Program.cs:line 17"

"NickHK" wrote:

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




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

No idea about the .Net stuff, but if you receive all those errors for a copy
statement, you have some work to do.
Check the documentation for the Copy method and see what it expects as a
destination; a string, range or what. With ( ) or without.

NickHK

"andalmeida" wrote in message
...
thanks, so i tried, but failed:

Excel.Range range = oExcelApp.Cells;
range.Copy("A1");

and got same exception:
"Copy method of Range class failed"
" at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)\r\n at Excel.Range.Copy(Object Destination)\r\n at
xlsconcat.Form1.button2_Click(Object sender, EventArgs e) in
C:\\Anderson\\xlsconcat\\Form1.cs:line 53\r\n at
System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at
System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)\r\n at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button,

Int32
clicks)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at
System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n at
System.Windows.Forms.Button.WndProc(Message& m)\r\n at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)\r\n
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&

m)\r\n
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)\r\n at
System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)\r\n

at

System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.Unsaf
eNativeMethods.IMsoComponentManager.FPushMessageLo op(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)\r\n at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)\r\n at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32

reason,
ApplicationContext context)\r\n at
System.Windows.Forms.Application.Run(Form mainForm)\r\n at
xlsconcat.Program.Main() in C:\\Anderson\\xlsconcat\\Program.cs:line 17"

"NickHK" wrote:

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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging Cells from C# and Interop Bjacaruso Excel Programming 0 October 11th 06 05:26 PM
Copy & paste cells fr open worksheet then close the worksheet Sin Excel Programming 1 October 2nd 06 02:20 PM
Copy (removing blank cells) without clipboard [email protected] Excel Programming 8 February 6th 06 12:32 AM
worksheet change event with .NET interop stavro Excel Programming 0 June 16th 05 05:57 PM
using the clipboard to avoid VBA / Interop Bob[_65_] Excel Programming 2 April 14th 05 02:23 PM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"