How do I open and save a password protected project plan using a m

M

Mark Main

From within a master project plan, that has several inserted project plan
files (with write access), how do I open and save a password protected
project plan using a macro?

Thanks for your help.
 
M

Mark Main

The FileOpen doesn't work quite right for me, because need this work work in
a master project plan (we don't run the server edition here) that has 15
project plan mpp files inserted into it (2 of the plans are password
protected for write access).

And because I need to do this at 3AM, I need to be able to open all 15 plans
in the master plan without human intervention (e.g. not needing mouse clicks
for warning message dialog boxes on the open, not getting asked to open the
pool, and not getting asked for the password).

any help is appreciated. Thanks.
 
R

Rod Gill

Use the different options of fileopen and before file open have a
DisplayAlerts=False. Reset to True before ending the macro otherwise the
user will lose all prompts and warning messages!

The only way to save a password protected file is by using the password in
the FileOpen statement.
 
M

Mark Main

Thanks Rod. I created my master plan to have all of the inserted project
plans minimized so that they don't try to open anything. Then I have my
macro do the FileOpen as you stated:
DisplayAlerts = False
FileOpen "C:\PMO\Project1.mpp", False, , , , , , , , , , pjDoNotOpenPool,
, "password", True

Then I call my NightlyPlanReview macro. What I don't feel is very clean
about my first attempt is how I decide to SAVE or NOT SAVE project plans. I
need to make this decision because sometimes people leave their project plans
open before the go home at night (and there's always the chance that they
have it open while I'm running my macro on all the plans and so I don't want
to save over their changes should they happen to save right during my macro
run). Here's what I do so far:

Sub SaveThisFile(originalFile As String, tempfile As String, saveflag As
Variant, tempProject As Variant)
'originalFile is the path/filename of the original file location
'tempfile is the path/filename of the current file location where the
macro run took place
'tempProject is the .Project name of the project that is now being saved
Dim i, iprev As Integer
If saveflag Then
'set ActiveProject to be the tempfile project
i = ActiveProject.Index
On Error Resume Next
Do Until ActiveProject.Name = tempProject
If i < 50 Then
i = i + 1
Projects(i).Activate
Else
i = 1
Projects(i).Activate
End If
Loop
'save the tempfile
FileClose pjSave
Else
On Error Resume Next
'close tempfile without a save
FileClose pjDoNotSave
End If
On Error GoTo 0
End Sub

It works, but I don't like that I had to force using <50 rather than taking
advantage of something like Projects.Count; but this didn't work because as I
FileClose various projects, Project.Count would reduce and sometimes I ran
into trouble where the Project.Index that I needed was a larger number than
what Projects.Count currently showed.

Is there a cleaner way to SAVE and CLOSE the project plans that I determine
as needing to be saved, and simply CLOSE the other plans.

Thanks again. By the way, is there a Timer available for use in MS Project?
I need to launch this at 3AM.
 
R

Rod Gill

Hi,

First the timer. I would use the Window Task timer to launch your
program/file.

You can loop through the Projects collection to see if a project is already
open. If it is you can close or save and close. Personally I would make this
a training issue and have the policy that any files left open will be saved
under a new name or closed. They'll only leave it open once!!
Sub test()
Dim Prj As Project
For Each Prj In Application.Projects
If Prj.Name = "Project im looking for" Then

End If
Next Prj
End Sub
 

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