dble

Close MS Project file, update Global.mpt, re-open file

7 posts in this topic

First just a quick question: Why does this fail?

Run("winproj.exe")

But this works?

ShellExecute("winproj.exe")

;----------

Main question - I want to write a script that:

  1. Closes MS Project completely
  2. Copies an updated Global.mpt file from the server
  3. Re-opens the same MS Project file the user was using 

I can pass the script a variable of the file name so re-opening should be easy. Copying is easy.

What is the best way to close MS Project? I would prefer not to kill the process, so I wanted to ask your advice. I will be calling this script from the On Open event of MS Project so I suppose I will not have to worry about saving.

 

Thanks much,

dble

Share this post


Link to post
Share on other sites



When using Run you have to specify "The full path of the program (EXE, BAT, COM, or PIF) to run" (according to the help file).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

To close MS Project I would try something like this (untested and without any error checking):

$oMSProject = ObjGet("", "MSProject.Application")
$oMSProject.FileCloseAllEx(0) ; Close all projects without saving them
$oMSProject.FileExit() ; Exit Ms Project

 

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks Water. I will work with your close example.

 

I did see that Run wants the path but I didn't understand why "calc.exe" or "notepad.exe" without the full path works fine.

Share this post


Link to post
Share on other sites

BTW, your code works perfectly

Share this post


Link to post
Share on other sites

One more question, I can't seem to find documentation on FileCloseAllEx(). Is there an option to "SaveAll"?

If a user had one file open, I updated the global, and then the user opened another file, the script would fire and all files would close and the first file wouldn't be saved.

Share this post


Link to post
Share on other sites

The MS Project Object Reference Model for MS Project 2010 can be found here.
All Methods, properties etc. for the application object can be found here.

$oMSProject.FileCloseAllEx(1) ; Close all projects and save them if needed

The enumeration PJSaveType can be found here (https://msdn.microsoft.com/en-us/library/ff867920(v=office.14).aspx).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now