My little prg was a proof of concept; not a bespoke solution to your conundrum. 
:-) 

If you just call the Copy method with no params it actually opens a new 
workbook. 

Use the command line and have a play. It's your best friend. It should be easy 
enough to make it do what you want to do. Use ox.Workbooks.Open() to open your 
target workbook. Set an object ref to that.

--

rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Paul Newton
Sent: Friday, February 17, 2017 7:35 AM
To: [email protected]
Subject: RE: Copy Excel worksheet to another workbook

Richard

Unfortunately, you are copying the worksheet to a new worksheet in the same 
workbook.
I want to copy the active worksheet to a new worksheet in a different workbook 
(which already exists), _without_ opening the target workbook ... still don't 
have a solution for that

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: 17 February 2017 12:14
To: [email protected]
Subject: RE: Copy Excel worksheet to another workbook

You're welcome, Paul.

I just played around in the command window with the Excel object til it worked. 
The beauty and power of VFP...

--

rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Paul Newton
Sent: Friday, February 17, 2017 3:46 AM
To: [email protected]
Subject: RE: Copy Excel worksheet to another workbook

Thanks Richard - you've given me some further ideas

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: 16 February 2017 18:04
To: [email protected]
Subject: RE: Copy Excel worksheet to another workbook

Clearly I'm avoiding doing anything productive right now.

**************************************
*    Program: FunWithExcel1.prg
*    Date: 02/16/2017 12:46
*    VFP Version: Visual FoxPro 09.00.0000.7423 for Windows
*    Notes: open a workbook, copies the 2nd sheet before the current 2nd sheet, 
makes another copy after the 3rd sheet
**************************************
ACTIVATE SCREEN
CLEAR
LOCAL m.ox AS Excel.Application, m.ow AS Excel.Workbook, m.oss AS 
Excel.Worksheet
m.ox=CREATEOBJECT([excel.application])
m.ox.Workbooks.Open([c:\rfc\copytest.xlsx])
m.ow=m.ox.ActiveWorkbook
?m.ow.Sheets.Count
m.oss=ow.Sheets(2)      && this example has 2 sheets. get a ref to the 2nd sheet
m.oss.copy(ow.Sheets(2))        && copy it before the 2nd sheet
?m.ow.Sheets.Count
m.oss.copy(,ow.Sheets(3))       && copy it after the 3rd sheet
?m.ow.Sheets.Count
m.ox.Visible=.t.

--

rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: Thursday, February 16, 2017 12:36 PM
To: [email protected]
Subject: RE: Copy Excel worksheet to another workbook

ox=CREATEOBJECT([excel.application])
ox.Visible=.t.
ox.Workbooks.Open(GETFILE([xlsx]))
ow=ox.ActiveWorkbook
ow.SaveCopyAs([c:\rfc\copytest.xlsx])
ox.Workbooks.Open([c:\rfc\copytest.xlsx])

This copies the entire document, not an individual sheet.
--

rk
-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Jan Bucek
Sent: Thursday, February 16, 2017 12:12 PM
To: [email protected]
Subject: Re: Copy Excel worksheet to another workbook

Dne 16.2.2017 v 17:48 Paul Newton napsal(a):
> Hi all
>
> I want to use automation to copy the active worksheet into another 
> workbook (as an additional worksheet) I believe I need something like 
> this ActiveSheet.Copy After:=Workbooks("YourWorkbookName.xls").
> Sheets("Sheet3") But I can't find how to send the correct way to do it 
> in VFP
>
> o = CreateObject("Excel.Application")
> o.Visible = .t.
> o.Workbooks.Open("C:\O32\OperaNext\Opera32\DEMODATA\SQSLACL.XLS")
> o.ActiveSheet.Copy(What to put here?)

And what about a little different way?

1. select all
2. copy
3. open another workbook
4. paste


>
> Any help would be much appreciated
>
> Paul Newton
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/bn4pr10mb0913c814dd03e8be92ebbbb3d2...@bn4pr10mb0913.namprd10.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to