


The procedure to record a macro and run when the sheet is loaded. I am using the following statement in a macro to insert data from a textįile into a excel sheet. > "C:\Program Files (x86)\Microsoft Office\Office12\EXCEL.EXE" M:\test.txt I am getting following errors: (trying to fix it but no result, any help appreciated)Įrror 20877 '.WorksheetClass' does not contain a constructor that takes '1' arguments C:\Documents and Settings\Taurus\My Documents\Visual Studio 2008\cartracker\WebApplication4\WebApplication4\Ĥ4 35 WebApplication4 Error 20878 The type or namespace name 'Cell' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Taurus\My Documents\Visual StudioĢ008\cartracker\WebApplication4\WebApplication4\ 45 41 WebApplication4 Error 20885 Cannot apply indexing with to an expression of type 'object' C:\Documents and Settings\Taurus\My Documents\Visual Studio 2008\cartracker\WebApplication4\WebApplication4\ĥ2 13 WebApplication4 Error 20886 No overload for method 'Add' takes '1' arguments C:\Documents and Settings\Taurus\My Documents\Visual Studio 2008\cartracker\WebApplication4\WebApplication4\ĥ3 13 WebApplication4 Error 20887 No overload for method 'Save' takes '1' arguments C:\Documents and Settings\Taurus\My Documents\Visual Studio 2008\cartracker\WebApplication4\WebApplication4\Ĭonsole.> and you just need a shortcut where the reference to Excel is followed by The base of this sample was borrowed from here : Private static void Safe(object misValue, Workbook excellWorkBook, string excellfilename)

ReleaseComObject(obj) Ĭonsole.WriteLine("Unable to release the Object " + ex) Private static void ReleaseObject(object obj) Safe(misValue, excellWorkBook, "") ĬloseQuitAndRelease(excellApp, excellWorkSheet, excellWorkBook, misValue) Var excellWorkSheet = (Worksheet) Ĭonst string InputfileName = "inputFile.txt" ĪddDataFromFile(excellWorkSheet, InputfileName)

Throw new ArgumentNullException("excellWorkSheet") ĮxcellWorkSheet.Cells = value Īpplication excellApp, Worksheet excellWorkSheet, Workbook excellWorkBook, object misValue)ĮxcellWorkBook.Close(true, misValue, misValue) Private static void AddDataFromFile(_Worksheet excellWorkSheet, string fileName) It uses a reference to 14.0.0.0 namespace ConsoleApplication2 I did put together this console app for you.
