ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy selected cells to new workbook? (https://www.excelbanter.com/excel-programming/343567-copy-selected-cells-new-workbook.html)

Chimanrao

copy selected cells to new workbook?
 
hi

This is the workflow which I am trying to achieve:

a. The user selecets multiple cells using the mouse
b. I have a com based plugin which adds a button to excel
c. On cliking of button I copy the the selected cells to new workbook.

How do I get the the selected cells and copy them to the clipboard?

Regards
Chimanrao


Chip Pearson

copy selected cells to new workbook?
 
Try

Selection.Copy

Note that many operations clear the clipboard, so you want to do
the Copy operation as close as possible to the Paste. Ideally,
the Copy and Paste operations will be on sequential lines of
code.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chimanrao" wrote in message
ups.com...
hi

This is the workflow which I am trying to achieve:

a. The user selecets multiple cells using the mouse
b. I have a com based plugin which adds a button to excel
c. On cliking of button I copy the the selected cells to new
workbook.

How do I get the the selected cells and copy them to the
clipboard?

Regards
Chimanrao




Chip Pearson

copy selected cells to new workbook?
 
I should have added that you can bypass the clipboard entirely by
specifying a destination in the Copy method. E.g.,

Selection.Copy
destination:=Workbooks("Book2.xls").Worksheets("Sh eet1").Range("A1")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chip Pearson" wrote in message
...
Try

Selection.Copy

Note that many operations clear the clipboard, so you want to
do the Copy operation as close as possible to the Paste.
Ideally, the Copy and Paste operations will be on sequential
lines of code.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chimanrao" wrote in message
ups.com...
hi

This is the workflow which I am trying to achieve:

a. The user selecets multiple cells using the mouse
b. I have a com based plugin which adds a button to excel
c. On cliking of button I copy the the selected cells to new
workbook.

How do I get the the selected cells and copy them to the
clipboard?

Regards
Chimanrao






Dave Peterson

copy selected cells to new workbook?
 
An unfortunate line wrap problem.

Chip's code goes on one line or use a continuation character so that it's still
one logical line:

Selection.Copy _
destination:=Workbooks("Book2.xls").Worksheets("Sh eet1").Range("A1")



Chip Pearson wrote:

I should have added that you can bypass the clipboard entirely by
specifying a destination in the Copy method. E.g.,

Selection.Copy
destination:=Workbooks("Book2.xls").Worksheets("Sh eet1").Range("A1")

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Chip Pearson" wrote in message
...
Try

Selection.Copy

Note that many operations clear the clipboard, so you want to
do the Copy operation as close as possible to the Paste.
Ideally, the Copy and Paste operations will be on sequential
lines of code.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chimanrao" wrote in message
ups.com...
hi

This is the workflow which I am trying to achieve:

a. The user selecets multiple cells using the mouse
b. I have a com based plugin which adds a button to excel
c. On cliking of button I copy the the selected cells to new
workbook.

How do I get the the selected cells and copy them to the
clipboard?

Regards
Chimanrao




--

Dave Peterson

Chimanrao

copy selected cells to new workbook?
 
Do the COM interfaces accept the destination?
I am using VC++.

Regards
Chimanrao


Dave Peterson

copy selected cells to new workbook?
 
Chip????


Chimanrao wrote:

Do the COM interfaces accept the destination?
I am using VC++.

Regards
Chimanrao


--

Dave Peterson

Chip Pearson

copy selected cells to new workbook?
 
They should, but I don't know for sure.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chimanrao" wrote in message
ups.com...
Do the COM interfaces accept the destination?
I am using VC++.

Regards
Chimanrao





All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com