|
-
Nov 17th, 2009, 03:48 PM
#1
Thread Starter
New Member
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
-
Nov 17th, 2009, 06:56 PM
#2
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 18th, 2009, 07:42 AM
#3
Thread Starter
New Member
Re: Open Excel and Save in VB6
Thanks RobDog888. I'll try this later today.
Paul
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|