General information
Category:
COM/DCOM and OLE Automation
Thanks for your helpful replies Tamar & Daniel,
Feel like I'm getting closer, but... I think I'm missing something here..
I am assuming that, as in the test macro I created to do this in Excel, the new sheet(s) would be also created as part of the copy.
Using your example, Tamar, I also added the optional Count parameter to create nPages -1 copies of Page 1. Now I get a syntax error at that line...
with oExcel
.WorkBooks.Open(cXLSfile)
.visible=.t.
.DisplayAlerts=.F.
cFooter='Created on '+left(cdow(date()),3)+', '+left(cmonth;
(date)),3)+' '+right(dtos(date()),2)+', '+;
left(dtos(date()),4)+' at '+left(time(),5)
.Sheets("Page 01").Select
.ActiveSheet.Cells.SpecialCells(11).Activate
nMaxExcelRows=.ActiveCell.Row
nMaxExcelColumns=.ActiveCell.Column
.Cells(1,1).Activate
nPages=int(nLineCounter/nMaxExcelRows)+5
***********************************************
.Sheets("Page 01").Copy(,.Sheets[1],nPages-1)
***********************************************
&&..some more processing
endwith
Any further suggestions would be appreciated
TIA
>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
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only