Issues with excel object
| UltraDangerLord (13) | |||
| Im getting a couple of errors....working with this excel object Any Help would be much appreciated. You can see a better looking example of the code here: http://share.codelove.org/BlahBlah-2BdWFb9Q.html The errors are: error CS1501: No overload for method 'Open' takes '2' arguments error CS1955: Non-invocable member 'Microsoft.Office.Interop.Excel._Workbook.Sheets' cannot be used like a method.
| |||
| Zaita (1607) | |||
Your problems are lines 36 and 37.
means that
wb = Microsoft.Office.Interop.Excel.Workbooks.Open(@"c:\test.xls",1);Is wrong, try using
Open(@"c:\test.xls"); without the
,1.
means that .Sheets is a variable, not a function.
sh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets(1);Try
sh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[1];Although, It maybe [0] because it should start from 0. But who knows with Microsoft. | |||
| UltraDangerLord (13) | |||
| Thanks Zaita, I got rid of 1 error with
sh = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[1];But the other one is lingering I tried:
wb = Microsoft.Office.Interop.Excel.Workbooks.Open(@"c:\test.xls");
wb = Microsoft.Office.Interop.Excel.Workbooks.Open(@"c:\\test.xls");
wb = Microsoft.Office.Interop.Excel.Workbooks.Open("c:\\test.xls");all the same error as before I also tried some wierd stuff.... such as:
which game me error code... error CS0079: The event 'Microsoft.Office.Interop.Excel.WorkbookEvents_Event.Open' can only appear on the left hand side of += or -= | |||
| Zaita (1607) | |||
| Did the Sheets error get solved? You need to know the Open() function's proper argument list then. I don't use Visual C++ so I can't tell you. But Intellisense should tell you what it is. | |||
| UltraDangerLord (13) | |||
| Yea the sheets error seems to be good now, much thanks Hey and i noticed that I list the class object as workbooks and then later... I use workbook... Thats the way i have seen it in examples... The intellisense does'nt list the correct options only 2.... Equal and ReferenceEqual also heres the msdn pages.. http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open(VS.80).aspx http://msdn.microsoft.com/en-us/library/bb179167.aspx lastly could it be something declared wrong in the class or namespace ? | |||
This topic is archived - New replies not allowed.
