How to open & save projects on project server 2003 by VBA code?

S

Shiny chen

Hi!Everybody.
I have a program in C#.NET,now I want to update my project's data on project
server 2003.
First I create a project Application object through VBA like this:

using MSP = Microsoft.Office.Interop.MSProject;
.........
MSP.ApplicationClass obj = new MSP.ApplicationClass();

But since URL,Account and password are needed when logging on a project
server,what I can do next? To login the server & open a online file?

I don't want to use MSP_PROJ_TASK_WRITEVIEW to update the project
data,because is so complicate to maintain the data correctly.

Thanks for help.
 
S

Shiny chen

:),I found that this question is given an answer by Adam Behrle before.

In fact,I used this way before I ask.My code is follow:
.......
System.Diagnostics.ProcessStartInfo Info = new
System.Diagnostics.ProcessStartInfo();
Info.FileName = "winproj.exe";
Info.Arguments = string.Format(@"/s ""{0}"" /u ""{1}"" /p
""{2}""", PrjSvrURL, PrjAcc, PrjPwd);
Info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
System.Diagnostics.Process Proc = null;

try
{
Proc = System.Diagnostics.Process.Start(Info);
System.Threading.Thread.Sleep(4000);

Microsoft.Office.Interop.MSProject.ApplicationClass obj =
new Microsoft.Office.Interop.MSProject.ApplicationClass();
......

If this is the only solution,something detail I want to solve:
Can't I hide the Project window when it working?
I tried obj.Visible = false; but does not work;
 
A

Adam Behrle

Shiny,

That seems to be a down side of this method. Because Project was
started from WinProj.exe, it doesn't think it is running in automation
mode (I believe). Setting the following will help some:

application.WindowState = pjMinimized;
System.Windows.Forms.Application.DoEvents();
application.DisplayWindowsInTaskbar = false;
application.Visible = false;
application.DisplayAlerts = false;
application.ScreenUpdating = false;

Hope that helps,

Adam
 

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