Jump to content

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


Recommended Posts

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...