Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel Syntax - copying one worksheet to another new one
Message
De
12/06/2001 11:01:31
 
 
À
12/06/2001 10:44:22
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00518215
Message ID:
00518403
Vues:
16
FWIW, for some strange reasons this syntax doesn't work in VFP. I've seen the same syntax error when using the move() method. In order to make this work under VFP, you need to assign the worksheet to copy/move to a memvar. The following code illustrates the problem and solution:
oXls=CREATEOBJECT("excel.application")
oXls.Application.Workbooks.Add()
oXls.visible=.t.

oXls.Sheets[1].Copy(, oXls.Sheets[3]) && Syntax error

oSheetToCopy = oXls.Sheets[1]
oSheetToCopy.Copy(, oXls.Sheets[3])   && works
I don't know the reason why the first line causes a syntax error. Anyway, the workaround is easy enough. As I said, the same applies to the move method.

>>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...
>>
>
>The issue is that the Copy method expects one of two parameters in this case: either the sheet to put the new sheet before or the sheet to put it after. That is, the syntax for copying a whole sheet is:
>
>oSheetToCopy.Copy( oSheetBefore , oSheetAfter )
>
>with the limitation that you specify either oSheetBefore or oSheetAfter, but not both. So the correct syntax for the command you're trying is:
>
>.Sheets["Page 01"].Copy(, .Sheets[x])
>
>Hope this helps.
>
>Tamar
Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform