Programatically Cancel Save in Project 98?

J

Jag Gill

Hello group -

P98 includes the Private Sub Project_BeforeSave(ByVal pj As
MSProject.Project). However, unlike some other Office 97 apps and
later versions of Project, there are no SaveAsUI or Cancel options to
allow interception of a save.

I have a master project, with inserted projects, and a custom
interface to enter and change task/resource and other details. I don't
want to allow users to save the master or inserted projects except
through the provided interfaces. This has to include re-saving it as
another project, which is the inevitable option when the project is
read-only. Because P98 doesn't support multi-user editing, the
likelihood is there will be situations that a user will be presented
with this option (either deliberately or accidentally). Indeed, when
the master project is being closed, any changes will prompt the native
'Save changes' dialog box for the master and inserted projects. I
can't even set the Saved property of the projects (because it is
read-only) prior to these triggering events to trick the application
and prevent the question being asked in the first place.

The essence of what I want to accomplish are captured below, but these
don't always prevent the users (typically novice, with very little, if
any, P98 skill) getting confounded by questions that they shouldn't
have to see:

Private Sub Project_BeforeSave(ByVal pj As MSProject.Project)
If pj.ReadOnly Or pj.WriteReserved Then
'# The following line doesn't seem to help
Set pj = Nothing
End If
End Sub

Private Sub Project_BeforeClose(ByVal pj As MSProject.Project)
If pj.ReadOnly Then Application.FileClose (pjDoNotSave)
End Sub

The BeforeSave code is as-is. My actual BeforeClose event is slightly
longer, as I am cycling through open projects to try and ensure that
no attempt is made to SaveAs any read-only inserted projects as well.

Private Sub Project_BeforeClose(ByVal pj As MSProject.Project)
For Each prjPlan In Application.Projects
With prjPlan
If .BuiltinDocumentProperties("Category").Value = "(master
project name)" Then
On Error Resume Next
Application.DisplayAlerts = False
.Activate '# not effective for inserted projects
If .ReadOnly Then Application.FileClose (pjDoNotSave)
Application.DisplayAlerts = True
On Error GoTo 0
End If
End With
Next prjPlan
End Sub

Desparately stuck and working with relatively archaic technology
(upgrading not an option) - all ideas and solutions welcome.

Many Thanks
Jag
 

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