I have WCF service running on windows XP under IIS 5.1. I have reference of
Microsoft.Office.Interop.Excel dll. I am creating an excel file at run time
and able to create application object as below but when i am trying to save
workbook I am getting below error :
Microsoft Office Excel cannot access the file 'file path'. 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
workbook.
I am trying to SAVE excel file at other server (not on the server where WCF
service is running) and my file path looks like this
\\holsanfs001d\Shared\Biz\BIZ
Teams\RA\Registered Agent\RA Invoicing which is different machine under same
domain.
Code sample: //Variable declaration
Application application = null;
Workbook defaultWorkBook = null;
bool bIsCreated = true;
try
{
//Instantiate excel application variable
application = new Application(); //This work fine and
instantiate the application object
application.Visible = false;
application.DisplayAlerts = false;
//Added workbook to excel file
defaultWorkBook = application.Workbooks.Add(Missing.Value);
if (defaultWorkBook != null)
{
//Save newly added workbook (Here I am getting above
error)
defaultWorkBook.SaveAs(filePath.ToString(),
XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, Missing.Value,
Missing.Value,
XlSaveAsAccessMode.xlExclusive,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
Any help will be very useful.
Thanks
Saki