Solved

.XLS to .XLSX Error

Posted on 2014-01-10
8
324 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
Comment Utility
Does this happen if you use workbooks created using Excel, rather than the third party program?
0
 

Author Comment

by:Cook09
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Cook09
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Accepted Solution

by:
Perarduaadastra earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Logical, if you think about it...

Many thanks for clarifying the solution.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now