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 10:49:19
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00518215
Message ID:
00518390
Views:
10
Ashley,
Sorry if my code was confusing. All you need to copy a worksheet is the following:
oSheetToCopy = oXls.Worksheets("Page 01")
oSheetToCopy.copy(, oXls.Worksheets(x))
This should work (where x refers to the worksheet after which you want to copy "Page 01").

>Hi Daniel,
>
>Thanks for the reply. I am not sure this will work for me as:
>I do not know the range in advance
>and I have 1 sheet that I will have to replicate n times
>
>..which is why I was trying to use the
>.Sheets("Page 01").Copy('After')=.Sheets(x)
>which will do what I want, only I seem to be running into syntax problems...
>
>
>
>>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
Reply
Map
View

Click here to load this message in the networking platform