Auto Republish Project batch job (console application in VB.net)

D

Divyesh

I am in process of writing a script that republishes Project. My problem is
how i can open all the enterpirse projects from the server at one time and
loop through them.
Below is my code. Using "projApp.FileOpenEx()" I am able to open one project
at a time from Project professional and then code saves that project,
republish it and close it. Please let me know if it is possible for me to
open all the project as same time and loop through it so code can save and
republish all project one by one.


Module Module1

Sub Main()
Dim strProj = "http://njcportal/pwa"
Dim projApp As New Microsoft.Office.Interop.MSProject.Application
Dim proj As Microsoft.Office.Interop.MSProject.Project
projApp.FileOpenEx()
Dim cnt
cnt = projApp.Projects.Count
For Each proj In projApp.Projects
'proj = projApp.ActiveProject
'projApp.UpdateProject()
projApp.FileSave()
System.Threading.Thread.Sleep(17000)
projApp.Publish()
System.Threading.Thread.Sleep(17000)
projApp.FileClose(PjSaveType.pjSave)

Next




End Sub

End Module
 
J

Jack Dahlgren

Divyesh,

It is not a good idea to open ALL the enterprise projects at the same time
because project will load them all into memory and your performance will
suffer. When I hve done this before I build a list of all the projects and
then go through that list using code like what you have below.

-Jack Dahlgren
 
D

Divyesh

Hi Jack,

Thanks for your reply. Please give me more detail on "build a list of all
the projects and then go through that list using code like what you have
below."
Our porject managers create new porjects everyday so I would also need to
keep up the list with modification.
1) When you say "create list of projects", where the list will get stored
and will it referance to server when my code republish it?
2) Is it possible to pick one by one project directely from Enterprise
Project pool and proecess them in my code instead of "saving a list of
Project"?
 
R

Rod Gill

The solution I've used in the past is to read the project titles from the
Reporting db then as Jack advised I opened, saved and published then closed
each file in turn: a good time for another coffee!

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
D

Divyesh

Hi Gill,

Please give me some basic idea how I can communicate with
Rporting DB and open each project one by one. I am trying to use
FileOpenEx() method (in VB). But I am geting hard time to open projects. This
wil be a great help to me to coplete my project.

Thank you,
Divyesh
 
D

Divyesh

I am getting Project name using Web service referance in my code and now in
order to open it i am using projApp.FileOpenEx(lo_projname,
PjFileFormat.pjMPP)
but it is not working. Since FileOpenEx is looking at physical location for
the project not the name of the project. Please assist me on how do i solve
it.
 
M

Maik

Hello Divyesh,

you have to set "<>\" in front of the projectName.

e.g

Dim currentProject as String

currentProject = "<>\" & projName

Greets
Maik
 
A

alex

Hi,

I don't know if you are familiar with .Net and webservices.
I have already done the program for the same scenario.
I remembered it's very simple to do that in .net
There is severa method provided by the SDK.
1\ get the project list
2\ publish each project by reading the queue to know the status of the task

I advise you to see the projTool proposed by Microsoft.

Best regards,
Alexandre BARAULT
 

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