S
stoods
Hi,
I am using c++ to export data into MS Project 2003. I can create a new
project without any problems, but just cannot get any collections of tasks or
resources into the project.
Even in the simple code I have below:-
// The one and only application object
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSPRJ.OLB"
rename_namespace("MSP") auto_search no_function_mapping
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit:GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
::CoInitialize(NULL);
// TODO: code your application's behavior here.
MSP::_MSProjectPtr m_App;
m_App.CreateInstance(__uuidof(MSP::Application));
MSP::_IProjectDocPtr m_Project = m_App->Projects->Add();
MSP::ResourcesPtr Resources = m_Project->Resources;
TRACE("Resources %d\n", Resources->Count);
::CoUninitialize();
}
return nRetCode;
}
I get an access violation exception whenever I try to access the count
property of the resources.
I am using c++ to export data into MS Project 2003. I can create a new
project without any problems, but just cannot get any collections of tasks or
resources into the project.
Even in the simple code I have below:-
// The one and only application object
#import "C:\\Program Files\\Microsoft Office\\OFFICE11\\MSPRJ.OLB"
rename_namespace("MSP") auto_search no_function_mapping
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit:GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
::CoInitialize(NULL);
// TODO: code your application's behavior here.
MSP::_MSProjectPtr m_App;
m_App.CreateInstance(__uuidof(MSP::Application));
MSP::_IProjectDocPtr m_Project = m_App->Projects->Add();
MSP::ResourcesPtr Resources = m_Project->Resources;
TRACE("Resources %d\n", Resources->Count);
::CoUninitialize();
}
return nRetCode;
}
I get an access violation exception whenever I try to access the count
property of the resources.