Solved

.XLS to .XLSX Error

Posted on 2014-01-10
8
337 Views
Last Modified: 2014-01-14
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.....
0
Comment
Question by:Cook09
  • 5
  • 3
8 Comments
 
LVL 15

Expert Comment

by:Perarduaadastra
ID: 39771966
Does this happen if you use workbooks created using Excel, rather than the third party program?
0
 

Author Comment

by:Cook09
ID: 39772175
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.
0
 
LVL 15

Expert Comment

by:Perarduaadastra
ID: 39772258
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...
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:Cook09
ID: 39772456
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?
0
 
LVL 15

Accepted Solution

by:
Perarduaadastra earned 500 total points
ID: 39772543
Is there anything in your code that assumes or implies one format or the other?

I have to wonder about exactly how Excel does the conversion from .xls to .xlsx, as all you're doing is taking an element of the saved .xlsx file and pasting it into another one.

Is it possible that Excel does a whole file conversion, as it were masking the original .xls format, and the pasted in section is actually still either in the old format once pasted in, or that the third party program doesn't strictly adhere to the old file format and so doesn't convert properly, at least on the first attempt?

With the file that you opened in step 9 above, if you then copied a worksheet from that into a new workbook would you still get the error?

At least the possibility of errors from a recycled macro have been eliminated...
0
 
LVL 15

Expert Comment

by:Perarduaadastra
ID: 39779900
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?
0
 

Author Comment

by:Cook09
ID: 39780243
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.
0
 
LVL 15

Expert Comment

by:Perarduaadastra
ID: 39780592
Logical, if you think about it...

Many thanks for clarifying the solution.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question