Creating a new excel file programatically

  • Thread starter Thread starter Chimanrao
  • Start date Start date
C

Chimanrao

I am writing a plugin with which , when the user clicks a button, I
want to save the active sheet in a new excel file.

How do I create a new excel file programatically?
howo do I add a existing sheet to this file?

Regards
Chimanrao
 
In the simplest form use.......

ActiveWorkbook.SaveAs Filename:="C:\Copy of Book.xls"

Sheets.Add
 
Try:

Sub newbook()
ActiveSheet.Copy
ActiveWorkbook.SaveAs "c:\Temp\MyNewBook.xls"
End Sub

Hope this helps
Rowan
 
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
Sheets.Add
ActiveWorkbook.SaveAs Filename:="C:\new book.xls"
 

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

Back
Top