[RESOLVED] Using Excel 2003 object to open *.xlsx file in VB6
Hi all,
I got an issue where using [VB6 + Excel 2003 + Office 2007 Compatibility Pack] to open *.xlsx (Excel 2007) file returns me the following error:-
Quote:
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.
Here is the sample code to open the file:-
Code:
Excel.Workbooks.open "<xlsx file>"
However the same method is applicable for Word 2003 to open *.docx file.
Another thing is the issue is only happen when open via VB6.
It has no problem to open normally by user (double click .xlsx file and it will convert accordingly if compatibility pack installed)
Is it a limitation or for security reason the feature is blocked?
Appreciate much if get feedbacks...
Re: Using Excel 2003 object to open *.xlsx file in VB6
try recording macro of opening file from excel
it may require insert method
Re: Using Excel 2003 object to open *.xlsx file in VB6
Good suggestion on the macro recording.
Programmatically opening the xlsx file may be missing some compatibility step or process that the compatibility pack is doing. I would think there is a conversion method invoked before its actually opened.
Re: Using Excel 2003 object to open *.xlsx file in VB6
Guys, i found an alternative solution to this issue already.
Code:
Call Shell("C:\Program Files\Microsoft Office\Office12\Moc.exe " & "C:\Book1.xlsx")
*Moc.exe is Open XML format converter provided after Office 2007 Compatibility Pack installed.
The Office 2007 Compatibility Pack will do the conversion job 1st before proceed to open the converted file (in temp folder). If the xlsx file is being open via [Excel 2003 > File > Open], it will be the same issue as via programmatically.
Thanks a lot guys for the suggestions which helped to guide me to the right way :)