PC Review


Reply
Thread Tools Rate Thread

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

 
 
Alek Luchnikov
Guest
Posts: n/a
 
      31st May 2007
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: alekluch---FORSPAMERS---(E-Mail Removed) REMOVE ---FORSPAMERS---



 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      31st May 2007
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


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Alek Luchnikov" <alekluch---FORSPAMERS---(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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: alekluch---FORSPAMERS---(E-Mail Removed) REMOVE ---FORSPAMERS---
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy and rename MS Excel sheet from MS Access VBA (MS Office 2000) Alek Luchnikov Microsoft Access Getting Started 2 31st May 2007 09:12 AM
Copy and Rename Access Table from Excel VBA =?Utf-8?B?SmFtZXM=?= Microsoft Access VBA Modules 6 6th Oct 2006 07:21 AM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd Microsoft Excel Programming 0 12th May 2006 01:31 AM
Button to copy sheet, rename sheet sequencially. foxgguy2005 Microsoft Excel Programming 9 17th Jun 2005 01:41 PM
rename invalid sheet name from access 97 report to Excel 2002 dls99 Microsoft Excel Misc 1 2nd Oct 2003 02:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:11 AM.