Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Syntax - copying one worksheet to another new one
Message
From
12/06/2001 03:43:12
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00518215
Message ID:
00518230
Views:
17
Ashley,
The following code may give you some ideas. It copies the first worksheet 10 times. Each copy is copied after the last worksheet.
oXls=CREATEOBJECT("excel.application")
oXLS.Application.Workbooks.Add()

oXls.visible=.t.
oSheetToCopy = oXls.Worksheets("sheet1") && object reference to the sheet we want to copy
oSheetToCopy.Range("A1").value = "Test" && add some text

lnWorksheets = oXls.Worksheets.count  && get total number of worksheets

FOR i = 1 TO 10
	oSheetToCopy.copy(,oXls.Worksheets(lnWorksheets))  && copy after last worksheet
	lnWorksheets = lnWorksheets + 1  && increase counter
	oXls.Worksheets(lnWorksheets).name = "sheet"+ALLTRIM(STR(lnWorksheets)) && rename added worksheet
ENDFOR &&* i = 1 TO 10
HTH
>Hi,
>
>I'm having trouble trying to copy a worksheet to another new one...
>I'm using:
>.Sheets("Page 01").Copy('After')=.Sheets(x) (where x is part of a loop to replicate the sheet as many times as required)
>
>Excel does not like the 'After'. I've tried sending it as a string, Boolean, Numeric without success.
>Can someone point me in the right direction?
>
>TIA
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform