J
Jim Darlington
The Setup
------------
Windows XP SP2 - 64 Bit.
Visual Studio 2005 SP1
MS Office 2003 (Word, Excel, Access InfoPath, PowerPoint, Publisher and
Project).
..NET 2.0
Microsoft Project 11.0 Object Library
The Requirements:
----------------------
Create a small WinForms program that opens a certain MS Project file and
exports all the tasks found inside it.
The Code:
------------
MSProject.ApplicationClass oApp = new
Microsoft.Office.Interop.MSProject.ApplicationClass();
oApp.FileOpen(strFileName, true, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
MSProject.PjPoolOpen.pjPoolReadOnly, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
foreach (MSProject.Project oProj in oApp.Projects)
{
foreach (MSProject.Task oTask in oProj.Tasks)
{
// Export the data
}
}
The Problem:
----------------
I'm getting the following exception on the first iteration of the inner loop:
Unable to cast COM object of type 'System.__ComObject' to interface type
'Microsoft.Office.Interop.MSProject.Task'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{000C0C3F-0000-0000-C000-000000000046}' failed due to the following error:
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).
Any help would be greatly appreciated. thanks
------------
Windows XP SP2 - 64 Bit.
Visual Studio 2005 SP1
MS Office 2003 (Word, Excel, Access InfoPath, PowerPoint, Publisher and
Project).
..NET 2.0
Microsoft Project 11.0 Object Library
The Requirements:
----------------------
Create a small WinForms program that opens a certain MS Project file and
exports all the tasks found inside it.
The Code:
------------
MSProject.ApplicationClass oApp = new
Microsoft.Office.Interop.MSProject.ApplicationClass();
oApp.FileOpen(strFileName, true, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
MSProject.PjPoolOpen.pjPoolReadOnly, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
foreach (MSProject.Project oProj in oApp.Projects)
{
foreach (MSProject.Task oTask in oProj.Tasks)
{
// Export the data
}
}
The Problem:
----------------
I'm getting the following exception on the first iteration of the inner loop:
Unable to cast COM object of type 'System.__ComObject' to interface type
'Microsoft.Office.Interop.MSProject.Task'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{000C0C3F-0000-0000-C000-000000000046}' failed due to the following error:
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).
Any help would be greatly appreciated. thanks