Question Locked

Access VBA, copy excel worksheet

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

1 reply

This discussion is closed to new replies.