PDA

View Full Version : Safe save file in *. xls



Artik
01-09-2011, 05:21 AM
Hi all Excelholics.

I want to save files in the XL97/2003 format (*. xls), regardless of whether it is running on XL2K3 or XL2K7+. XlFileFormat type (in XL 2K7) contains two constants: xlWorkbookNormal and xlExcel8. Both will save the file in *. xls.
Are there differences in the file is saved using xlWorkbookNormal and xlExcel8? Can I safely use a constant xlWorkbookNormal to save the file regardless of the version of Excel?

I apologize for my language. I use a translator.

Artik

Tokinabo
01-09-2011, 07:13 AM
Excuse me for not coming with the answer.
You already know that xlExcel8 is used for saving in version 97-2003.
What is the reason you want to use xlWorkbookNormal instead and take chances it can go wrong?

Artik
01-09-2011, 09:00 AM
What is the reason you want to use xlWorkbookNormal instead and take chances it can go wrong? Because the file can be run on versions lower than 2K7.
In versions below 2K7, there is no constant xlExcel8. But there is a constant xlWorkbookNormal. I know that I can use a condition in which version of the workbook is running, but I would avoid it if possible.

Artik

CaptRon
01-12-2011, 11:12 PM
I have attached a workbook that demonstrates the method I use to direct the user to save the workbook in the 97-2003 .xls format.

Hope you find it useful.

Ron

Jan Karel Pieterse
01-13-2011, 01:49 AM
See:
http://www.rondebruin.nl/saveas.htm

Artik
01-13-2011, 12:43 PM
I thought that there will not be more willing to engage in a dialogue. Thank you.

But the question is a bit different.
Is there any difference in saving file (by SaveAs) using a constant xlExcel8 or xlWorkbookNormal? In the XL 2K7 both methods result in saving a file in *. xls.
Otherwise.
Should I expect some of the dangers of saving a file using the following code fname = "My workbook in 2K3 format"
ThisWorkbook.SaveAs Filename: = fname, FileFormat: = xlWorkbookNormal
I want to use this code in versions of 2K3 and 2K7 + in the shortest form. As I wrote previously, I know other methods to save the file (checking the version of the application running.)

Do you now understand my problem? :-)

Again, sorry for my language.

Regards

Artik

Artik
01-22-2011, 05:00 PM
Up. :pleased:

Artik

Jan Karel Pieterse
01-23-2011, 11:22 AM
I understand you always want to save the file in 97-2003 mode. The code on Ron de Bruin's site should get you there and I do not think you can get away with not testing the version of Excel.

Artik
01-23-2011, 02:53 PM
I understand you always want to save the file in 97-2003 mode.Yes, absolutely.

I thought it would be a good my idea to use xlWorkbookNormal.
As I understand it is not a 100% certain solution.
Thank you Jan (and others) for the response, although I continue to wonder why M$ gave us a choice between xlWorkbookNormal and xlExcel8.

Artik

CaptRon
01-23-2011, 03:24 PM
Artik,

The example I submitted to you earlier utilizes code I found on Ron De Bruin's site. I used the part that I needed to direct a save in the Excel 2003 .xls format (FileFormat: = -4143). It works well in both Excel 2003 and Excel 2007.

I changed that piece of code to FileFormat: = xlWorkbookNormal, ran it is 2003 and 2007, and it works just as well in either.

So, apparently -4143 and xlWorkbookNormal can be used interchangably.

Ron

Jan Karel Pieterse
01-24-2011, 04:40 AM
CaptRon:
xlWorkbookNormal *should* save your file in the default file type for that particular Excel version, which differs between 97-2003 and 2007/2010 respectively obviously.

CaptRon
01-24-2011, 05:00 PM
CaptRon:
xlWorkbookNormal *should* save your file in the default file type for that particular Excel version, which differs between 97-2003 and 2007/2010 respectively obviously.

Hmmmm... Know what? I had my Excel 2007 set to save in the .xls format by default. So, I changed my default to .xlsx and found that FileFormat:=xlWorkbookNormal saved the workbook as .xls anyway.

With a clean workbook (format yet unassigned), ActiveWorkbook.Save resulted in an attempt to save as .xlsx (I got the message about losing macros in the .xlsx format) because I had my default set to save as .xlsx.

Using ActiveWorkbook.SaveAs FileFormat:=xlWorkbookNormal resulted in a save as .xls even though my default was .xlsx.

I poked around in the VBA help file and found that -4143 I have been using to direct a save as .xls is the numerical value for xlWorkbookNormal.

xlWorkBookDefault (51) does save as the default file format setting regardless of the workbook's pre-existing file format.

Ron

Jan Karel Pieterse
01-25-2011, 10:52 PM
OK, I mixed up two thing obviously. Thanks for setting me straight!