A friend needs a favor from me...
I need to "corrupt" an excel file so it wont open
I cant just delete the file becuase thats too obvious
How can I make the excle file still there but wont load.
I tried opening it in wordpad...and deleting the 1st 20 rows...
and that sort of works but it still kind of loads.
I know this sounds fishy...but many of you know me and you know Im doing anything funny (like creating a virus! )
any Ideas?
-Static
Last edited by Static; Feb 25th, 2005 at 01:49 PM.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
An easy easy way to break this is to take any file (a Zip for example) and copy it to the file making sure that the file extension becomes .XLS. When Excel tries to open the file it will be reading and looking for certain file structures/signatures/etc... so it will fail. A nice easy method....
Using the code I attached in my above post, you then need:
Code:
Dim lngIndex As Long
Dim bytData() As Byte
Dim bytNew() As Byte
Dim lngUBound As Long
Dim lngMid As Long
bytData = GetFile("C:\Woof.xls")
lngUBound = UBound(bytData)
lngMid = lngUBound / 2
ReDim bytNew(lngUBound)
For lngIndex = 0 To lngMid
bytNew(lngIndex) = bytData(lngUBound - lngMid + lngIndex)
Next lngIndex
For lngIndex = lngMid + 1 To lngUBound
bytNew(lngIndex - lngMid - 1) = bytData(lngIndex)
Next lngIndex
SaveFile "C:\new.xls", bytNew
When I try to open the xls file it says it doesn't recognise the form.
This seems to work, but a better way would be to take the byte array:
1234567890
And then split in half
12345
67890
and then interweave the bytes
6172839405
That would bust any file
But you cans till get the file back by doing the reverse.
A nice way would be to change the file in such a way so you reverse the change if really needed.
You can use the NOT operator to reverse the bytes in the file, and if you reverse again, then the file will be readable again, same way you can use XOR.
Here's what I mean:
VB Code:
Option Explicit
Private Sub ReverseByteNumbers(ByVal FileName As String)
Dim K As Long, byteArr() As Byte, FL As Integer
FL = FreeFile
Open FileName For Binary Access Read Write Lock Read Write As FL
ReDim byteArr(LOF(FL) - 1)
Get FL, , byteArr
For K = 0 To UBound(byteArr)
byteArr(K) = Not byteArr(K)
Next K
Put FL, 1, byteArr
Close FL
End Sub
Private Sub XORFile(ByVal FileName As String, XORNumber As Byte)
Dim K As Long, byteArr() As Byte, FL As Integer
FL = FreeFile
Open FileName For Binary Access Read Write Lock Read Write As FL
ReDim byteArr(LOF(FL) - 1)
Get FL, , byteArr
For K = 0 To UBound(byteArr)
byteArr(K) = byteArr(K) Xor XORNumber
Next K
Put FL, 1, byteArr
Close FL
End Sub
Private Sub Form_Load()
ReverseByteNumbers "C:\TestFile.xls"
XORFile "C:\TestFile 2.xls", 200
End Sub
I did not actually try this code...
If you run the same function on the "damaged" file, it will fix it back...
Hi,
You can try using this manual process to recover your workbook:
1- Click File > Open.
2- Click the location and folder that contains the corrupted workbook.
3- In the Open dialog box, select the corrupted workbook.
4- Click the arrow next to the Open button, and then click Open and Repair.
5- To recover as much of the workbook data as possible, pick Repair.
A friend needs a favor from me...
I need to "corrupt" an excel file so it wont open
I cant just delete the file becuase thats too obvious
How can I make the excle file still there but wont load.
I tried opening it in wordpad...and deleting the 1st 20 rows...
and that sort of works but it still kind of loads.
I know this sounds fishy...but many of you know me and you know Im doing anything funny (like creating a virus! )
any Ideas?
-Static
Change an image file's extension to .xlsx. That should do it
A friend needs a favor from me...
I need to "corrupt" an excel file so it wont open
I cant just delete the file becuase thats too obvious
How can I make the excle file still there but wont load.
I tried opening it in wordpad...and deleting the 1st 20 rows...
and that sort of works but it still kind of loads.
I know this sounds fishy...but many of you know me and you know Im doing anything funny (like creating a virus! )
any Ideas?
-Static
Change an image file's extension to .xlsx. That should do it