Link to home
Start Free TrialLog in
Avatar of Cook09
Cook09Flag for United States of America

asked on

.XLS to .XLSX Error

Bacground...
Two workbooks are created from a third party program.  Initially, they are created as an .xls file.  Each workbook is reformatted, through a VBA macro, with the button on the QAT. The macro is located in PERSONAL.xlsb. Workbooks 1 and 2 are saved as a .xslx file through the macro.  No code exists within the workbook.

Manually, a worksheet from workbook 2 is copied to workbook 1. No changes are made to this worksheet.

The problem....
1. Workbook 1 is again saved as an .xlsx file after the worksheet is copied to it.  
2. In attempting to reopen this closed workbook 1, an error appears that workbook 1 is either in the wrong format, or corrupted.

Initial work around....
1. To solve this, the workbook is renamed to .xls and reopened, then resaved as an .xslx file.
2. After performing this process, the workbook will open correctly.

This is problematic as most of this process is done within VBA, and others who will be using this code, eventually won't, if they have to rename and then resave, or it is just left in the .xls format...which is taking a step backward.

Any thoughts.....
Avatar of Perarduaadastra
Perarduaadastra
Flag of United Kingdom of Great Britain and Northern Ireland image

Does this happen if you use workbooks created using Excel, rather than the third party program?
Avatar of Cook09

ASKER

Actually, it does.  Like your question may imply, something within the other program is causing this, but I ran the test as follows.

1. Exported the data to Excel in the usual manner.
2. Did a copy and paste of the data into a newly opened worksheet.  This also included the formats, but no worksheet to workbook copy which is different.
3. After the four tabs were copied, then ran the macro, and saved it as a .xslx file.
4. Exported a second workbook, and copied the data into the first one (copy and paste).
5. Resaved the workbook and closed (.xlsx).
6. Tried to open the workbook, through windows explorer, and it just seemed to flash, but nothing. Tried it two more times, it would not open.
7. Changed the .xlsx to .xls and clicked to open...which it did.
8. Resaved it as a .xlsx file and tried to open
9. It did open with all the data intact.

So back to the original question...copying data from a .xls file to .xlsx file??

One note, it is stored on a company network, but I don't think that should matter for a .xslx file.
Two possibilities come to mind.

First, the data you refer to is exported to the Excel worksheet. What happens if you create the data in the new Excel workbook/sheet and then repeat the operation that's causing the problem?

Secondly, is the VBA macro you use for reformatting newly written for this task, or is it an existing one that has been edited to do the job? In either case, check it very carefully for errors; if it's new the problem may be a tiny error somewhere in the code, whereas if it's a modified pre-existing one something may have been left in it from its original purpose that torpedos its new function.

I know doing such tests is tedious and has no guarantee of pinpointing the problem, but it may be less tedious than eventually discovering that they would have revealed the cause if only you'd done them...
Avatar of Cook09

ASKER

Well one of the questions I have is if the code is being called from Personal.xlsb, does it leave any "markers," that would create a scenario where it's not fully ".xlsx?"  The code was written from scratch and for this, but what would cause it to "have to be" .xls prior to being .xlsx?
ASKER CERTIFIED SOLUTION
Avatar of Perarduaadastra
Perarduaadastra
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In order to make this question more useful to the EE community, would you be kind enough to indicate what the problem was, and the suggestion that actually fixed it?
Avatar of Cook09

ASKER

A third party program would create two workbooks as .xls files.  Code was added to reformat and save the main workbook as an .xlsx file, in the appropriate subdirectory.  After that was completed, then the second workbook (.xls) had a worksheet that needed to be reformatted and copied into the .xlsx workbook, then the bundle was saved in the .xlsx format.

The problem occured in attempting to reopen the Workbook.xlsx. An error would occur that indicated it was either corrupted or not of the same type.

The solution was to copy the reformatted .xls worksheet into the xls workbook prior to saving it.  Excel couldn't open a workbook that was being saved with two different worksheet formats. As long as each worksheet was of the same type, then Excel could convert and properly save the entire file, with no issues in reopening the newly created .xlsx workbook.
Logical, if you think about it...

Many thanks for clarifying the solution.