Page 1 of 1

Need some help with VBA in Excel 2007

Posted: 2010-11-22 02:34pm
by eyl
I'm having a bit of difficulty with a VBA function in Excel 2007; I'm hoping someone might have an idea how to solve it.

During the course of the program, I need to add a new workbook. Usually, I'd simply use WorkBooks.Add (the Add method for the WorkBooks collection). The catch is that I need the new workbook to be in Excel 2007 format (since I need more than 256 columns in the worksheet). It's my understanding that WorkBook.Add opens the new workbook in the format which is currently set as the default, which is Excel 2003 in my case, and indeed I'm getting 256-column worksheets. I'd rather not change the default to xlsx.

Does anyone know of a way to force the creation of the new workbook in xlsx format?

Thx

Re: Need some help with VBA in Excel 2007

Posted: 2010-11-22 05:51pm
by phongn
Take a look at the reference documentation here - in particular the second example. If you immediately save the file, you can set various fields in the SaveAs method such as the new format.