This is where the error is...(if you need to see more code let me know)
if (employeeID == "134")
{
oXL.Sheets[new string[2] { "134", "134_ManagerComments" }].Copy();
and the compiler is highlighting the [new string[2]] and telling me on new:
Identifier expected; 'new'is a keyword and on string
Expected class, delegate, enum, interface, or struct
How should this be ammended in order to remove these errors?
Loading
VulpesRank #55 · 29.2K reputationPosted Feb 13, 2013, 6:10 AM EST
What that error suggests to me is that there's a problem with your curly braces in code earlier in the file with the result that this method doesn't appear to the compiler to be part of a class.
So, I'd re-examine the code in the light of that.
VulpesRank #55 · 29.2K reputationPosted Feb 13, 2013, 5:00 AM EST
I'd see if it makes any difference if you split it up like this:
richard smithRank #8,268 · 225 reputationPosted Feb 13, 2013, 5:22 AM EST
public static void copySheets()
{
Excel.Application oXL;
if (employeeID == "134")
{
oXL.Sheets[new string[2] { "134", "134_ManagerComments" }].Copy();
}
richard smithRank #8,268 · 225 reputationPosted Feb 13, 2013, 6:17 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 13, 2013, 6:35 AM EST
The following is a real killer in a console app which has caused some head-scratching in its time:
The code builds OK but produces the following exception:
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts