K
Kevin M
I am using Microsoft Office 11.0 Object Library. The code runs fine on
Windows Server 2003.
Below is the code sample.
============================================================================
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
Excel.Application m_ExcelApplication = new Excel.Application();
m_ExcelApplication.Visible = false;
m_ExcelApplication.UserControl = false;
m_ExcelApplication.Application.ScreenUpdating = false;
m_ExcelApplication.DisplayAlerts = false;
string strFileName = @"d:\testing\testing.xls";
Excel.Workbook m_ExcelWorkBook =
m_ExcelApplication.Workbooks.Open(strFileName, //FileName
2,
//UpdateLinks
bReadOnly,
//ReadOnly
Type.Missing,
//Format
Type.Missing,
//Password
Type.Missing,
//WriteResPassword
true,
//IgnoreReadOnlyRecommended
Type.Missing,
//Origin
Type.Missing,
//Delimiter
false,
//Editable
Type.Missing,
//Notify
Type.Missing,
//Converter
Type.Missing,
//AddToMru
Type.Missing,
//Local
Type.Missing
//CurruptLoad
);
===============================================================================
When executing the Open function. I received the following exception:
Microsoft Office Excel cannot access the file 'd:\testing\testing.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
workbook.
However, when I removed the directory information and just give it the file
name: 'testing.xls' - I putted testing.xls in to the same directory as the
Windows Service- everything works fine.
Please help.
Any help will be greatly appreciated.
Thanks
Windows Server 2003.
Below is the code sample.
============================================================================
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
Excel.Application m_ExcelApplication = new Excel.Application();
m_ExcelApplication.Visible = false;
m_ExcelApplication.UserControl = false;
m_ExcelApplication.Application.ScreenUpdating = false;
m_ExcelApplication.DisplayAlerts = false;
string strFileName = @"d:\testing\testing.xls";
Excel.Workbook m_ExcelWorkBook =
m_ExcelApplication.Workbooks.Open(strFileName, //FileName
2,
//UpdateLinks
bReadOnly,
//ReadOnly
Type.Missing,
//Format
Type.Missing,
//Password
Type.Missing,
//WriteResPassword
true,
//IgnoreReadOnlyRecommended
Type.Missing,
//Origin
Type.Missing,
//Delimiter
false,
//Editable
Type.Missing,
//Notify
Type.Missing,
//Converter
Type.Missing,
//AddToMru
Type.Missing,
//Local
Type.Missing
//CurruptLoad
);
===============================================================================
When executing the Open function. I received the following exception:
Microsoft Office Excel cannot access the file 'd:\testing\testing.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
workbook.
However, when I removed the directory information and just give it the file
name: 'testing.xls' - I putted testing.xls in to the same directory as the
Windows Service- everything works fine.
Please help.
Any help will be greatly appreciated.
Thanks