Open Excel and Save in VB6
I have a legacy vb6 program that writes out an Excel formatted .xls file. It uses the Formula One spreadsheet control (Old Control, company no longer in business). Occasionally this control writes out a bad file and it nor Excel can read it. As you can imagine this causes a big problem when this happens.
I am going to switch to Spread 8 and have fixed the troublesome Form to create both a Formula One .xls and a Spread 8 .xls. This works. The Spread 8 .xls file can be read with Excel version 2003.
My problem is that when I go to read the .xls created with Spread 8 back in to the Formula One control in another form it says that it is an Invalid File.
However, if I open the Spread 8 .xls in Excel 2003 and just save it, no changes made, as a 2003 .xls then Formula One will read it.
My question is how can I open the Spread 8 .xls in VB6 and save it as an Excel 2003 .xls. I know how to open the .xls in VB, but I don't know how to save it as an Excel 2003 formatted .xls.
Any help would sure be appreciated.
If I can't do this in VB code, my option is to re-write a fair amount of legacy VB code when our plans are to move to .net at the end of next year.
Thanks
Paul
Re: Open Excel and Save in VB6
Using the SaveAs method and pass the proper fileformat argument.
http://www.vbforums.com/showthread.php?t=408487
Note the "FileFormat:=xlWorkbookNormal" argument.
The reason why it opens after being saved in excel even though no changes is that excel will save it in the proper file type as Formula One may not be writting the correct file header information.
Re: Open Excel and Save in VB6
Thanks RobDog888. I'll try this later today.
Paul