A: 

What user is the service running as? Make sure that user has access to the specific file.

sontek
Service is running as LocalSystem. Where should I check in XP for said permissions.
Gromer
Permissions isn't the issue now that you've posted your error :)
sontek
+1  A: 

It seems most likely that it is a permissions issue. Windows services run under a different user account than desktop applications.

Also, you mention that you are executing this method every x amount of time. Make sure you are using the right timers. http://www.aspfree.com/c/a/C-Sharp/Timer-Objects-in-Windows-Services-with-C-sharp-dot-NET/

And you should be able to attach a debugger to the service by using "Attach to Process" and selecting your host process. This might give you more info on your problem. http://msdn.microsoft.com/en-us/library/7a50syb3(VS.80).aspx

svarcoe
Don't have any devenv on the machine we can test this on, so attaching a debugger won't work. I have yet to have any luck trying to remotely attach a debugger.As for the timer, we are using a System.Threading.Timer.I might try to log the service on as a user to see what happens.
Gromer
A: 

You could try making it a shared workbook (Tools > Share Workbook). This lets multiple users edit the same workbook concurrently. I'm not sure if that would work for you as some workbook features get locked down when it is shared

barrowc
When it is shared, the C# code cannot get the latest data from the Excel file :( It only gets the last saved data.
Gromer
+1  A: 

Excel doesn't allow you to open a file simultaneously. You need to either create it as a shared workbook or make a copy of the file and work off of the copy.

There is also full excel API (Microsoft.Office.Interop.Excel) that you could try using, which would allow you to hook into the currently opened excel/workbook.

sontek
+3  A: 

In addition to @sontek's answer.

[only applicable If you are the owners/developers of the Spreadsheet in question...]

You may find it easier to work with a "data push" model rather than a "data pull" model. It's usually an easier programming model to push the data via an excel macro directly into your data store, based upon some event from your plug-in. this is often a much better scenario than a service polling on a timer.

Tim Jarvis
I have never messed around with any of the Excel macro stuff. Initial Google search makes me think this could be the best option. I'm assuming the Excel macro can detect changes to cells and then fire off the logic?
Gromer
Yes, definitely. Events are fired at multiple levels, Cell events would be handled at the sheet level (other levels are Application, Workbook and Chart) and you get the Cells that have changed passed to the handler as a range.
Tim Jarvis
Some sample code here http://support.microsoft.com/kb/302815
Tim Jarvis
Oh and of course some VBA code (for your macro) here...http://www.cpearson.com/excel/Events.aspx
Tim Jarvis
Marking this as the "answer" because it gave us a "better" idea.
Gromer
A: 

SpreadsheetGear for .NET can open a file even if Excel currently has the file open and it is well suited to using from a Windows Service.

However, the file on disk will not reflect changes which have not been saved by Excel, and SpreadsheetGear would not be able to open a workbook while Excel is in the middle of saving, so the service would have to take that into account.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson