How to copy and rename MS Excel sheet from MS Access VBA (MS Office 2000)

A

Alek Luchnikov

Hello, All!
I want to copy and rename excel sheet from ÁÓÓÅss vba.

I try this but result is error:

Sht.ActiveWorkbook.WorkSheets("Sheet2").Copy
Before:=Sheet.ActiveWorkbook.WorkSheets(1)
or
Sht.WorkSheets("Sheet1").Copy Before:=Sheet.WorkSheets(1)

I know how to add sheet, insert data from access into sheet & else.
My searching in internet return nothing.
Is anybody know how do this ????
Thank you in advance.

With best regards, Alek Luchnikov.
E-mail: (e-mail address removed) REMOVE ---FORSPAMERS---
 
D

Douglas J. Steele

The following works fine for me:

Sub ExcelStuff()

Dim objExcel As Object
Dim objWorkbook As Object
Dim strFile As String

strFile = "C:\Folder\File.xls"

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.workbooks.Open(strFile)
objWorkbook.Sheets("Sheet1").Copy Before:=objWorkbook.Sheets(1)
objWorkbook.Close SaveChanges:=True
Set objWorkbook = Nothing
objExcel.Application.Quit
Set objExcel = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top