Deleting comments causes Unreadable Content Error

dan_m101

New Member
Joined
Nov 26, 2011
Messages
47
Hello fellow board members, I'm using Excel 2010 and getting very odd program behavior, maybe you can help me?

If you do the following:

-Open a new blank .xlsm workbook
-Select a cell in sheet1 (say B2) add a comment to it and then an image
-Select another cell below in sheet1 (say B4) add a comment to it and then an image
-Delete the first comment.
-Save the workbook
-Reopen the workbook

The following error message appears:

"Excel found unreadable content in ...Do you want to recover the contents of this workbook? If you trust the source of this workbook, click yes"

After clicking yes, I get a message saying the program managed to repair the file by removing the unreadable content.

"Removed Part: /xl/drawings/vmlDrawing1.vml part. (Drawing shape)"

I converted the originally corrupt .xlsm file to .zip, looked at the file in question through a text editor and saw this:
<v:fill o:relid="rId2" o:title="e8" color2="#ffffe1"
<v:fill o:relid="rId2" o:title="e8" color2="#ffffe1"
<v:fill o:relid="rId2" o:title="e8" color2="#ffffe1"

<v:fill o:relid="rId2" o:title="e8" color2="#ffffe1"
v:fill o:relid="rId2" o:relid="rId1" o:title="e8" color2="#ffffe1"

I know from online resources that Excel 2010 does not like having duplicate o:relid parameters with different values (Here we have two IDs: rId2 and rId1 tied to the same comment). It seems like o:relid parameters are just added on to the line, with the most recent identity being the last one (in this case rId1). I found a vbScript online that does resolve the problem (attached below), but it only works if you first convert the corrupt excel file to .zip and then open and modify /xl/drawings/vmlDrawing1.vml. Since the project I'm working on will be updated very frequently and by multiple users, it isn't feasible to do this all the time. I was trying to run the vbScript every time you save the excel workbook by using the Workbook_BeforeSave sub but I really have no clue how to access vmlDrawing1.vml and change its contents since it is part of the open excel file. Does anyone have an idea?. If it isn't possible to do this, does anybody know any other means to stop this error from occurring in the first place, maybe some service pack or hot fix that I'm missing?

******************************
vbScript:

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFSO2 = CreateObject("Scripting.FileSystemObject")
Set fileInfo = oFSO.GetFile("/xl/drawings/vmlDrawing1.vml") ' this gives an error saying file not found, probably because the excel file wasn't converted to a .zip file...

' create new file
sFile2 = fileInfo.parentFolder & "\Fixed_" & fileInfo.Name
If oFSO.FileExists(sFile) Then
Set oFile2 = oFSO2.CreateTextFile(sFile2)
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
' read through input file one line at a time
sText = oFile.ReadLine
iStartPos = 0
iStartPos = InStr(sText, "o:relid=")

' if an o:relid is found we do special processing
If iStartPos > 0 Then
' keep appending lines from the input file until we reach o:title
iTitlePos = InStr(sText, "o:title=")
While iTitlePos = 0
sText = sText & oFile.ReadLine
iTitlePos = InStr(sText, "o:title=")
Wend

' find the LAST o:relid if there are more than one
iNextPos = InStrRev(sText, "o:relid=")
If iNextPos > 0 And iNextPos > iStartPos Then
' this is the last o:relid
sItem = Mid(sText, iNextPos, iTitlePos - iNextPos)
' replace the multiple o:relid with only the last one
sText = Left(sText, iStartPos - 1) & sItem & Mid(sText, iTitlePos)
End If
End If

oFile2.WriteLine (sText)
Loop
oFile.Close
WScript.Echo "Done"
End If

******************************
vbScript thanks to scadam and dlauzon on this microsoft support forum: Excel Worksheet and backups suddenly get Unreadable Content Message - Microsoft Community

Thanks for any help!</v:fill></v:fill></v:fill></v:fill>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,216,028
Messages
6,128,392
Members
449,445
Latest member
JJFabEngineering

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top