Search the forums and or google for that error code (without the minus sign). There seem to be a number of possible causes.
You need to do some debugging yourself. Put some probes in the code to see exactly where the error is first occuring. That can give you a clue as to what is going on.
You have a lot of odd file open, get file position, set position to end, and close in between the the write to spreadsheet files. You certainly don't need to get the file position. You are just setting it to the end. But simpler yet would be to use a Write to Spreadsheet File, and wire a 1-D array of strings to the 1-D input. Then you don't have to do all the extra string concatenation.
If you do use the Write to File functions, don't forget to wire up the error wires there also.
Another issue, you are mixing and matching text file and Excel functions with your File. Your file writes create a text file. But then you go and open it up in Excel. That is going to import the text file into Excel and start treating it like a real Excel spreadsheet. If you later go and run your code on that same file again, you are going to wind up corrupting the .xls file by putting in more text at the end of a proprietary .xls file format.