Create new Excel file

F

FrankAlva

Hi,

I would like to create a new excel file from scratch using VBA.
Here's what I got so far

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

Set xlApp = CreateObject("excel.application")
Set xlBook = xlApp.Workbooks.Open("c:\test.xls", 0, False, 2)
Set xlSheet = xlBook.Worksheets(1)

Now that is to create a new excel file from and existing on
"test.xls". How would I do it to create one without having an existin
one.

Something like Set xlBook = xlApp.Workbooks.New ??

thank
 
B

Bob Phillips

Frank,

Have you tried

Set xlBook = xlApp.Workbooks.Add(Template:="Workbook")


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
G

Guest

Where should this code go? In an existing Excel file, xla file, or xlt file?

Bob Phillips said:
Frank,

Have you tried

Set xlBook = xlApp.Workbooks.Add(Template:="Workbook")


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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