Programmatically call WINPROJ.EXE (2007) from .NET

M

mahesh

Hi
In Project Web Access /Project center it will display list of Projects
When we click on icon it will open Project professional 2007 with selected
Project.

I need to do the same concept .I am displaying list of projects as per my
view in Grid view, all project names as Hyperlinks.
When the user clicks on Hyper Link the Project professional has
to open with selected project.

For this I am writing code in this way but it is showing error

private void start()
{
objProcess = Process.Start(@"winproj.exe", "/s http://Server/PWA");

}

private void OpenPrj()
{
backgroundThread = new System.Threading.Thread(new ThreadStart(start));
backgroundThread.Start();
System.Threading.Thread.Sleep(10000);
Microsoft.Office.Interop.MSProject.ApplicationClass
objProject = new ApplicationClass();
objProject.Visible = false;
object oMissing = System.Reflection.Missing.Value;
object oFile = @"<>\aaTestStatusCode.Published";
object oUserName = "xxxxx";//"MSProjectUser"; // Project
server database user
object oPassword = "pass@word1";//"tcs@12345"; // project
server database password
object oURL = "http://Server/PWA";
objProject.DisplayAlerts = false;
objProject.FileOpen(oFile, oMissing,
(object)(Microsoft.Office.Interop.MSProject.PjMergeType.pjDoNotMerge),
oMissing, oMissing, oMissing, oMissing, oUserName, oPassword,
(object)("MSProject.odbc"), oMissing,
Microsoft.Office.Interop.MSProject.PjPoolOpen.pjDoNotOpenPool, oMissing,
oMissing, oMissing, oMissing);
objProject.ActiveProject.Application.BaselineSave(true,
PjSaveBaselineFrom.pjCopyCurrent, PjSaveBaselineTo.pjIntoBaseline, true,
true, true);
objProject.ActiveProject.Application.PublishAllInformation();
}
Error Details

Error Message: "An unexpected error occurred with the method."
Error Code=1004

at System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)\r\n at
Microsoft.Office.Interop.MSProject.ApplicationClass.FileOpen(Object Name,
Object ReadOnly, Object Merge, Object TaskInformation, Object Table, Object
Sheet, Object NoAuto, Object UserID, Object DatabasePassWord, Object
FormatID, Object Map, PjPoolOpen openPool, Object Password, Object
WriteResPassword, Object IgnoreReadOnlyRecommended, Object XMLName)\r\n at
WindowsApplication1.Form1.btnOpen_Click(Object sender, EventArgs e) in
C:\\Custom
Applications\\Test\\WindowsApplication1\\WindowsApplication1\\Form1.cs:line
80"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top