Republish from VBA Script

D

devnull50

I am trying to write a script which will recalculate a project and then
publish the project. I am opening the file using ODBC, recalculating
and saving without a problem. When I publish I get an error "You are
trying to publish a non-enterpirse project to Project Server". This
project is indeed an enterprise project that I opened from the project
server. How can I accomplish this?



Here is the code:

DIM psApp,pj

Set psApp = CreateObject("MSProject.application")
psApp.FileOpen("<ProjectServer>\project.Published")
psapp.CalculateAll()
'psapp.FileSave()
call psApp.PublishProjectPlan()
psapp.FileClose()


Thanks!
-Jim
 
R

Rod Gill

Hi,

One way is to make sure Project Professional is started in online mode for
publishing to work.
The way you'll need to do this is to first start Microsoft Project in the
enterprise mode so that the enterprise methods you send to it will work.
You can do this similarly to:

Dim objMSProject As MSProject.Application

'Start MS Project in enterprise mode - assigning the results to the
'variable x so that the results can be tested to see if the application
even starts. A return value does
'does not guarantee
x = Shell("Winproj.exe /S http://servername/projectserver /U username
/P password", vbHide)
DoEvents 'this gives Project time to logon
'Create a project application:
Set objMSProject = CreateObject("MSProject.Application")
DoEvents

'Hide it:
objMSProject.Application.Visible = False
objMSProject.EnterpriseProjectImportWizard

If you omit the /U (username) and /P (password) parameters, then its
assumed that a Windows Logon will be attempted.
 

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