VB[A] Way to force new workbook to be in xlsx format?

ou81aswell

Board Regular
Joined
Oct 6, 2009
Messages
50
I'm automating Excel through COM.

I have a user who is running Excel 2010. His version of Excel is set to save files in the Excel 97 - 2003 format (*.xls) which is limited to 65,536 rows.

I have a piece of code that produces a recordset from a database and then writes it to a new sheet. Often, there are more than 65,536 rows in it.

On this user's machine my code fails when it blows past the 65,536 row limit because the new workbook it creates is in .xls format instead of .xlsx format.

Is there a way for my code to force Excel to create the new workbook in xlsx format?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I believe you should be using the Workbook FileFormat property in your code, but hard to suggest exactly without seeing the component of the code that creates the new workbook. From Excel help:

Workbook.FileFormat Property (Excel)

Returns the file format and/or type of the workbook. Read-only XlFileFormat.

Syntax
expression.FileFormat

expression A variable that represents a Workbook object.

Remarks
Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you've selected or installed.

Example
This example saves the active workbook in Normal file format if its current file format is Excel 97/95.

VBA
Code:
If ActiveWorkbook.FileFormat = xlExcel9795 Then

    ActiveWorkbook.SaveAs fileFormat:=xlExcel12

End If
 
Upvote 0

Forum statistics

Threads
1,214,660
Messages
6,120,787
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top