Question
March 16, 2007 at 02:53 AM
bruntius

Access VBA, copy excel worksheet

by bruntius . Updated 19 years, 7 months ago

Hey all – self teaching VBA but only posting here as a last resort as I cannot find the answer.

The following code from my access 2002 database opens a workbook then adds a new work sheet that i can then write stuff to. But what i need to to is open the workbook then copy and existing worksheet to write stuff. This is doing my head in. Can anyone help ??

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(“c:\somefile.xls”)
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Cells(1, 5).Value = “Gday!”

Thanks and Regards
MB

This discussion is locked

All Comments