Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5958065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:29:25+00:00 2026-05-22T18:29:25+00:00

I have an Excel wrapper class using the Office PIAs. I also have a

  • 0

I have an Excel wrapper class using the Office PIAs. I also have a limited test suite that was previously written to run on NUnit. We are migrating to TFS2010 at work so I’m migrating the NUnit test overs to MSTest as well.

The test suite runs fine on my dev machine and if executed manually with MSTest command line utility on the machine that runs the build agent. However, when executed through Team Build all the tests that have anything to do with disk I/O (Open, Save, etc) fail. My build agent is running on a domain account and that domain account is also a local admin on the same machine. The few tests that do not do any disk I/O run fine, so I know Excel is being fired and available. Just seems like a permissions issue or a limitation of the Team Build process.

So here’s an example function. This is what makes me think it’s an Excel I/O issue. The File.Exists check passes fine. I’m not receiving a FileNotFoundException in my test run, instead I’m receiving a COMException directly from the interop layer.

public void OpenXLS(string workbookFilePath) 
{
   // Make sure given file path exists
   if (!File.Exists(workbookFilePath))
   {
      throw new FileNotFoundException(String.Format(CultureInfo.CurrentCulture,
         "File '{0}' cannot be found.", workbookFilePath));
   }

   // Open the Workbook
   _xlsWorkbook = _xlsWorkbooks.Open(workbookFilePath, 0, false, Missing.Value,
      "", Missing.Value, true, Missing.Value, Missing.Value, true, false,
      Missing.Value, Missing.Value, Missing.Value, Missing.Value);
}

The Exception:

System.Runtime.InteropServices.COMException: Microsoft Excel cannot access the file 
'C:\BuildPath\TestResults\TestRun\Out\TestBook.xls'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:29:25+00:00Added an answer on May 22, 2026 at 6:29 pm

    I had similar problem and this solution worked for me:
    http://blogs.msdn.com/b/sqlserverfaq/archive/2010/04/30/unable-to-open-excel-files-using-a-cscript-in-sql-server-jobs.aspx

    A “Desktop” folder seems to be necessary in the “systemprofile” folder.

    • Create the “Desktop” folder for Windows 2008 Server (x64) under the location C:\Windows\SysWOW64\config\systemprofile

    • And for a 32 bit Windows 2008 Server create the “Desktop” folder under the location C:\Windows\System32\config\systemprofile

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary I have written an Excel wrapper in .NET using Visual Basic and Visual
I have Excel add-in which I add so many class modules that it is
I have wrote a code that can read an excel 2007 file using Microsoft
I have a macro that needs to run for update. If Excel is in
We have an Excel 2002/XP based application that interacts with SQL 2000/5 to process
I have an Excel 2003 workbook that contains a macro to copy certain of
I have an excel sheet full of times. They are formatted so that they
we have a C++ Win32 DLL that reads data from Excel. The application uses
I have an excel spreadsheet that has dates in the first column, the rest
I have an excel sheet that is loaded with a dynamic result set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.