Windows 7: "Excel found unreadable content" - windows-7

I'm using PHPExcel to generate a very simple .xls file (PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5')). Whenever that file is opened on Windows 7 using Excel 2010 or 2007, I get the following error:
Excel found unreadable content in 'XXXXXXX.xls'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.
When I open the same file in Excel 2010 in Windows XP it works fine. If I open the same file in OpenOffice, it works regardless of the OS.
Windows 7 / Excel 2010: Error
Windows 7 / Excel 2007: Error
Windows XP / Excel 2010: Works
Windows XP / Excel 2007: Works
Any / OpenOffice: Works
When I tell PHPExcel to generate an .xlsx file (PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel2007')), it works fine with all the above combinaisons.
I found countless threads on the MS forums, and it seems to affect only Windows 7 files with Excel files generated by third party libraries (not just PHPExcel). But no one has a solution.
I also found the following MS KB article, but I'm not familiar with the underlying Excel specifications: http://support.microsoft.com/kb/2411912
Has anyone else experienced this?

If it is the problem you've highlighted from the MS Support site, then it's locked somewhere in the innards of PHP_OLE, probably in the PHPExcel_Shared_OLE_PPS_File class. I've raised this as Issue 15508 on the PHPExcel site, and will try to run some debugging over the weekend on a Windows 7 box.
No guarantees of a quick fix: but you've given me a pointer on how to try and recreate the problem, and where to look.

For me it was fixed when I used proper UTF-8 encoded strings instead of ISO-8859-1. Maybe PHPExcel can hint about bad encodings?

You have to write with UTF-8 the title, creator, LastModifiedby etc... fields. This was my solution.

Related

Problem opening Office URI Scheme urls in Office.js on Mac/Safari

I'm developing a JavaScript addin for Office applications, e.g. Word, Excel and PowerPoint. At some point it should open a file that resides somewhere in SharePoint.
I want the url to open the correct Office application right away and for this purpose I'm using Office URI Schemes (see https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes?redirectedfrom=MSDN).
Depending on the logic in the app, I'm using two different techniques, which work perfectly when the addin is running in Word, Excel or PowerPoint on Windows.
Technique 1 (normal link)
Open Me!
Technique 2 (programmatic)
// Js pseudo code
button.onclick = () => {
window.location = 'ms-word:ofe|u|https://foo.sharepoint.com/path/to/file.docx'
}
As I mentioned, both these techniques works flawlessly on Windows. But when running the addin on e.g. Word Desktop on Mac, absolutely nothing happens. I've debugged the addin, by using "Inspect Element" to open up the console, but there's no errors or anything. It seems to me that the internal browser on Mac silently refuses to open the link.
However, if you paste the link into e.g. a word document, it will open the document if clicked.
Some thoughts:
is this related to the manifest.xml for the addin? (still works on windows without modifying the manifest)
do I need to enable something on Mac for this to work? (the Office URI Scheme page states these links should work on Office for Mac 2011)
Any input is greatly appreciated.
I found a workaround that works on Mac as well by using window.open(url).

Copy a picture between Excel 2010 spreadsheets without causing saving errors

I have a macro to copy data and a picture from one workbook (A) to another workbook (B). Workbook B is in Excel 2010. The code works fine if workbook A is an earlier version of Excel such as 97-2003. But if workbook A is also in Excel 2010 format, the code seems to work but upon trying to save the file I get an error ("Errors were detected while saving 'C:...'. Microsoft Excel may be able to save the file by removing or repairing some features...").
The key part of the code (after opening workbook A) is:
For Each s In workbookA.Sheets
If s.Pictures.Count > 0 Then
For Each pic In s.Shapes
If Left(pic.Name, 3) = "Pic" Then
pic.Copy
workbookB.Activate
Worksheets("Sheet1").Range("A1").Select
ActiveSheet.Paste
GoTo gotPicture:
End If
Next pic
End If
Next s
gotPicture:
workbookA.Close
The error is resolved by deleting the picture. Or by saving and closing Workbook B prior to closing Workbook A. Neither of those is a great solution. From my research it sounds like this is an error within Excel 2010 where you can't copy pictures between spreadsheets generally rather than a VBA issue. There might be a patch, but corporate policies and the number of users who will need to run the macro make that a bad option for me.
Is there a good way to get around this? Some way to copy a picture between Excel 2010 spreadsheets that doesn't cause this problem? Thanks.
Ran into this same issue. Got around it by keeping my source documents open until my destination workbook was saved (which, as you point out, isn't great). Hotfix patch from Microsoft:
https://support.microsoft.com/en-us/help/2597034/you-cannot-save-a-workbook-that-contains-an-image-that-was-copied-from

PDF generated has font issue after window server upgrade

After I have moved from Windows Server 2003 to Windows Server 2008 R2, the PDF font issue was encountered.
The description of the issue:
Using Window Server 2003, crystal report is used to export the report to PDF. Using the object tool option in PDF to select the string, we can see the string below contains in one box. (*not enough reputation to post images)
'abcde'
However when Window Server 2008 is used, a different string is produced.
'abcd' 'e'
As you can see, the string is separated into 3 boxes when windows server 2008 is used. Hence, I am unable to use a simple java program to read the string due to the added spaces (about one pixel difference).
The crystal report engine has not been changed. Hence, I susupect that it is due to the window server font issue, but have no idea how to rectifty this issue.
Hope someone has a solution to this problem.
Any help will be appreciated!

Word 2003 template with VBA macros that does not run properly in Word 2011 for MAC

As the title says, I've got a word template with macros that does not run properly in the new Word version from Office 2011 for MAC.
The thing which seems to not work properly is the following code:
Sub Document_New()
myForm.Show
End Sub
The same is with Document_Open()
It doesn't seem to run this code on the Mac version.
Does anyone know why this won't work on the Mac, or if there's another way around to emulate the document_open/document_new function?
EDIT: The document is in the .dot format. And I tried to save it to .doc, then the Document_open() worked just fine, so it seems to not be working in the .dot format.. And Document_New() is not running in .doc since its not a new templatefile based on a document..
EDIT 2: Seems like it was a once only with the Document_open on .doc files. I cant make it work again. So weird! The only event I get working, and this is only when using the .doc file format, is Document_Close() - this works everytime...
EDIT 3: This is just getting weirder. I made a new .doc document with the following code:
Private Sub Document_Open()
MsgBox ("BlaBlaBla")
End Sub
The code only runs if the Visual Basic Editor is open BEFORE I close the word file and try to open it again. If I close the Visual Basic Editor and then the word file, and then open the word file; The code is not run.
??
All VB application events are suppressed if you have the VB-editor active, and the current project is not running. It is an intentional behavior, to prevent unwanted code execution, hence not debuggable.
I have used Workbook_Open() (in Excel), and I can only see it working on newly open Excel Xls (xlsm on 2010), from a non-open VB-editor Excel application.
It will work if you have other doc/xls already open, but not if vb-editor is up.
Have you checked whether Macros are allowed? Do you have generated a certificate and setup your application as a trusted source?
I'm having similar issues. It seems that MS removed support for the Document_New and Document_Open functions in the Word object model for Word 2011. See http://mac2.microsoft.com/vb/1033/Word/html/womscChangesBetweenWord2010and2011.htm

Blank text editor in Vis Studio

I have just installed VS 2005. I created a project. I added code to the project and then debugged the code. The program ran ok. I save the project. Everything saves fine. I go to open the project and the text editor is blank, or so it appears. After further investigation I notice that the code is there but I just can't see it. I debug and the program runs but no code can be seen. Strange. What is additonally weird, is I have installed the python idle and it to is blank, no code to be seen. However, the code is in there because I can run the code. I have adjusted just about every display property in VS as well as the os display props. I am using a Dell Latitude M60 Laptop, w/ windows xp professional, sp2, intel pentium M, 2 Ghz, 1gb ram. What do you think? Any body have this happen to them?
Could it be.. Right_Mouse+Click on the file in the Solution Explorer and chose "View Code"?
sometimes windows needs a restart :-)

Resources