>I'm copying a "template" sheet within a workbook in order to make one sheet for each employee. I want to add a sheet called "Cindy" to the current workbook - either at the end (
Sheets(Count)
) or after some particular sheet.
>
>I have
lcSheetType = "Monthly"
>lcEmployee = "Cindy"
>oExcel.Sheets(lcSheetType).Copy()
which creates a new workbook and puts a sheet called "Montlhy" in it - but I want it to be in the current workbook! The docs say the syntax I need is
Worksheets("Sheet1").Copy after := Worksheets("Sheet3")
but I can't translate this into anything I can use.
>
>Help is appreciated!
Hi Cindy,
it is not a big deal. :)
If you try to substitute the parameter with worksheet name or number it does not work because it has to be an object reference:
A sample:
ox = createobject("excel.application")
ox.visible = .t.
oWorkbook =ox.ActiveWorkbook
obefore = oWorkBook.Sheets(2)
oWorkbook.Sheets(3).Copy(oBefore)
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro
"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison