View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default XL07 - How to conditionally determine Workbook file format compatibility in VBA?

Hi Keena

I see no other way on this moment then use the CheckCompatibility dialog in the macro

Something like this that try to save as xls first and if you press cancel it save as xlsm
I try to find another way to test it without answering the dialog with Continue or cancel

Sub test()
On Error Resume Next
With ActiveWorkbook
.SaveAs "C:\Users\Ron\Test\aa.xls", 56
If .Name < "aa.xls" Then
.SaveAs "C:\Users\Ron\Test\aa.xlsm", 52
End If
.Close True
End With
End Sub

I will look for more information this weekend
Maybe others have a better suggestion


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"keeena" wrote in message ups.com...
Thanks for the help...look forward to your reply. Also sent request
to Microsoft.

I hope it doesn't require jumping through hoops...like saving in 2
different formats, opening & comparing.

One thing I've found: a file with XL07 content saved can be saved with
a .XLS extension. Windows & Excel 07 will think file type is 97-2003
due to the extension. However, it will throw a warning upon opening
with XL07...XL07 thinks file is corrupted because content doesn't
match given extension. It will open OK w/ the XL07 content (e.g.
80,000 rows of data).

If its possible to catch this warning/error, then my Save method could
force-save w/ .XLS extension (no FileType specified) and then open the
file. If the warning message pops up, then I know the FileType needs
to be .XLSX.

What I don't know is if I can check for this error/warning. But
someone out there w/ more experience may know...

GL...hope you're able to find *something* that I may be able to use.

-K

On Jul 20, 1:03 pm, "Ron de Bruin" wrote:
Hi keeena

I never looked for this.
If you use workbooks.add it will add a workbook with the format as your default file format in Excel.

I will test/try a few things today/tomorrw and post back

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm