Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello:
When "Copy or Move" sheet, in the dialog there is an opportunity to define a workbook to copy the sheet to. However if I created a macro, it does not reflect my choice, i.e., it comes the same whether I define or not define a workbook. Furthermore, when I run the created macro Sheets("sheet").copy the first time, it places a copy of sheet "sheet" as "sheet (2)" in the same book. However, when run the second time it creates a new workbook without my meaning to. My question: is there a way to specify in the macor the workbook a sheet is to be copied to. Thank you, Alex |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello.
You need to specifically state the workbook object that is your destination... like this: Workbooks("Book3").Sheets("Sheet1").Copy After:=Workbooks ("Book2").Sheets(1) the "Book3" would be your workbook's name, or it could be better to use a workbook object to do it. But, it's the "After" parameter that you need to set to do what you're trying to do. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mark, thank you.
You see, I do that from inside Java. For me it looks like Sheets sheets = Workbook.getSheets(); Sheet sheet = sheets.getItem("sheet"); sheet.copy(sheet); where the argument sheet in the copy method means "Before", which I presume as suitable as "After" to my ends. So inside the parentheses a sheet is a sheet (that came from a certain workbook.) There is no way for me to specify sheets as an additional argument. I would expect that something like sheet.activate(); would work, but it does not. In fact, I never want a second book, but only the one I start with. Should not there be a default somewhere? Thank you, Alex mark wrote: Hello. You need to specifically state the workbook object that is your destination... like this: Workbooks("Book3").Sheets("Sheet1").Copy After:=Workbooks ("Book2").Sheets(1) the "Book3" would be your workbook's name, or it could be better to use a workbook object to do it. But, it's the "After" parameter that you need to set to do what you're trying to do. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I haven't used Java to do it... sorry.
-----Original Message----- Mark, thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook | Excel Worksheet Functions | |||
Excel-how to link source workbook to copy of destination workbook | Excel Worksheet Functions | |||
Copy cells based on conditions in one workbook to another workbook | Excel Worksheet Functions | |||
copy worksheet from closed workbook to active workbook using vba | Excel Worksheet Functions | |||
Copy a range of cells in an unopened workbook and paste it to the current workbook | Excel Programming |