Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Getting error while converting excel 2007 file to 2003 file in vb6


Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2008, 10:53 AM
anant_sutariya anant_sutariya is offline
Newcomer
 
Join Date: Dec 2008
Posts: 2
Default Getting error while converting excel 2007 file to 2003 file in vb6


I am having ms office 2003 installed on my developement machine, and i have also installed compitible package for office 2007 excel. Now i want to convert 2007 excel file to 2003 excel file.
when i try to open the xlsx, it gives me prompt msg like below, with ok cancel, first thing i want to remove this prompt message.

This file is not in a recognizable format.

• If you know the file is from another program which is incompatible with Microsoft Office Excel, click Cancel, then open this file in its original application. If you want to open the file later in Microsoft Office Excel, save it in a format that is compatible, such as text format.
• If you suspect the file is damaged, click Help for more information about solving the problem.
• If you still want to see what text is contained in the file, click OK. Then click Finish in the Text Import Wizard.

Another thing is that if i try to convert this to 2003 excel file it with below code it gives me error like
err.number 1004 -- Application-defined or object-defined error

this is my code.

Dim xlsAppObj As New Excel.Application
Dim xlsWrkObj As Excel.Workbook

xlsAppObj.Workbooks.Open TEMP_PATH & fileName ' first prompt message comes here
Set xlsWrkObj = xlsAppObj.ActiveWorkbook
xlsWrkObj.SaveAs TEMP_PATH & fso.GetBaseName(fileName) & ".xls", 56 'error while saving to 2003 version
xlsWrkObj.Close False

Any help would be appricated. Thanks in advanse
Reply With Quote
  #2  
Old 12-19-2008, 04:33 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

Not sure what you are trying to do here but the Excel file must be compatable with Excel 2003 (If you know the file is from another program which is incompatible with Microsoft Office Excel, click Cancel, then open this file in its original application. If you want to open the file later in Microsoft Office Excel, save it in a format that is compatible, such as text format).

Excel 2007 files are not compatable with 2003.

If you want your program to be able to read Excel 2007 files and save them as a 2003 file you need to use the
Quote:
Microsoft Excel 12.0 Object Library
you can then open the Excel 2007 files and use the SaveAs method to specify saving the XLS as version 2003.
Quote:
MyWorkBook.SaveAs "whatever.xls", xlExcel9
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #3  
Old 12-23-2008, 03:43 PM
anant_sutariya anant_sutariya is offline
Newcomer
 
Join Date: Dec 2008
Posts: 2
Default

thank you very much for ur reply.

What i am trying to do is i want to convert excel 2007 file to excel 2003 format. and i have MS office 2003 with compitible package for office 2007 excel.

As per ur posting, i will not able to convert if i dont have Office 2007 installed on my machine.

But i can open xlsx file directly from windows explorer, can it be possible in programming.

Any pointer would be appreciated.

Thanks,
Anant
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->