Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy a sheet in an Excel workbook
Message
From
15/06/1999 15:02:56
 
 
To
15/06/1999 10:58:15
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00227990
Message ID:
00230107
Views:
48
Perry,

That is definitely not a stupid question, but no I am using the correct names. I found the answer by using the following:

oleApp.Worksheets('sheet1').copy(.null.,oleApp.Worksheets('sheet2'))

For some reason I have to specify the .null. I tried it with just a blank followed by the comma and an empty string '' but neither worked.

Finally I got the answer and it is working great for me, thanks for your help in giving me some direction on where to go.

Mark

>Mark,
>
>I don't mean to ask a stupid question, but did you rename any of the sheets so sheet1 or sheet2 is not actually the sheet name? The commands as you have typed them work fine for me.
>
>PF
>
>>Perry,
>>
>>I am not sure what I could be doing wrong. I am doing the following:
>>
>>oleApp = CREATEOBJECT("Excel.Application")
>>oleApp.Visible=.t.
>>oleApp.Workbooks.open(curdir()+"crosstab.xls")
>>oleApp.Worksheets('sheet1').copy(,oleApp.Worksheets('sheet2'))
>>
>>The result of the last command is a syntax error.
>>
>>Are you adding any spaces or anything else that I may be missing?
>>
>>Mark
>>
>>>Mark,
>>>
>>>Are you sure you typed the command in properly with the comma before the parameter to indicate its parameter #2. I just tried the command you typed in, adding the comma and the copy ended up after sheet2.
>>>
>>>Pf
>>>
>>>
>>>>Perry,
>>>>
>>>>I have tried that, but it generates a syntax error.
>>>>
>>>>Mark
>>>>
>>>>>Mark,
>>>>>
>>>>>I don't have a chance to try this, but in the copy() part, the first paramter is the before parameter and the second one is the after. So, as I understand it, you would type
>>>>>
>>>>>".copy(,oleApp.Worksheets('sheet2'))" && note the ,
>>>>>
>>>>>to copy after sheet2.
>>>>>
>>>>>Give it a try.
>>>>>
>>>>>PF
>>>>>
>>>>>>What I have been able to do so far is to create a copy of the sheet before an existing sheet by using:
>>>>>>
>>>>>>oleApp = CREATEOBJECT("Excel.Application")
>>>>>>oleApp.Visible=.t.
>>>>>>oleApp.Workbooks.open(curdir()+"crosstab.xls")
>>>>>>oleApp.Worksheets('sheet1').copy(oleApp.Worksheets('sheet2'))
>>>>>>
>>>>>>This will work except that I need to have an extra page in the workbook and then delete it when done. I just can't find the proper syntax for passing the parameter to copy the page after an existing sheet. The help example I have found uses what VB calls Named Parameters which it can interpret and pass internally, but I can't find anything that defines the parameters for the Copy method.
Mark Johns
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform