I get the following error:
Unable to create instance of class TestProject.TestClass. Error: System.Runtime.InteropServices.COMException: 'D:\Automation\TestProject\OBJECT_DEFINITIONS.XLS' could not be found. Check the spelling of the file name, and verify that the file location is correct. If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.
Error Stack Trace:
Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
TestProject.TestLibrary.GetObjectDeclarations(String sModule) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\TestLibrary.cs: line 133
TestProject.TestClass..ctor() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\TestClass.cs: line 51
code:
using Excel = Microsoft.Office.Interop.Excel;
namespace TestProject
{
[TestClass]
public class TestLibrary
{
public string[] arrObj = new string[19];
public string[] arrConfig = new string[12];
public string sobjfile;
.
.
.
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(sobjfile, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
I am wondering why is the error saying D:\Automation\TestProject\OBJECT_DEFINITIONS.XLS
could not be found when I have OBJECT_DEFINITIONS.XLS
stored in C:\