I am writing to determine if anything as part of the evaluation process would break/modify VB code in an excel spreadsheet. Here is the scenario, I have a fairly complex Excel Spreadsheet with several sheets and lots of VB code. What I'm trying to do is automate a process via the web that will insert my starting data into this Excel Spreadsheet. I have accomplished this with very little code and that part works fine. Here is my code:
- Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(@sDriveLetter + ":\\inetpub\\files\\reports\\templates\\Tech_Template.xls", ExcelVersion.Version97to2003);
Worksheet worksheet = workbook.Worksheets[0];
worksheet.InsertDataTable(tblFinal, false, 2, 1);
worksheet.InsertDataTable(tblRefHistory, false, 2, 27);
workbook.SaveToFile(@sDriveLetter + ":\\inetpub\\files\\reports\\TechReview-" + DateTime.Now.Year + DateTime.Now.Day + iSecond + ".xls", ExcelVersion.Version97to2003);
Now when I open the spreadsheet I see the eval sheet but then errors start happening. I first get a generic:
File error: data may have been lost
And then I start getting all sorts of visual basic errors about being unable to access parts of the document. If I try to modify any parts of the spreadsheet via the VB scripts I start getting errors about unprotecting the sheet but there is no protections on the sheet before and as far as I can tell there are none after the data has been saved.
I have even tried just opening the file and saving the file without adding anything and the error still happens. So it seems to be just the opening and closing of the spreadsheet is causing all sorts of errors.
So my questions are:
1. Does the eval version do anything to the VB code in excel
2. Should my document be coming up as protected after I open/save it? If so, is there a way to prevent this.
Thanks,
Richard