709-218-7927

The Landfall Garden House

60 Canon Bayley Road

Bonavista, Newfoundland

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

(Home) Most-Recently Used (MRU) , What is Most-Recently Used? ; AutoSave and AuditSave , The Environment , Triggers , File Save Actions , File Close Actions , What About Third-Party Triggers? , Slave Functions , What about MRUse? , FileSaveAll, FileCloseAll, FileExit , The Set Of Procedures , lSaveAs , lClose , lFolderExists , lFileExists , lFileOverwrite , mFileSave , mFileSaveAs , mFileClose , FileSave , FileClose , FileSaveAs , FileSaveAll , FileCloseAll , DocumentClose , FileExit ,

The Set Of Procedures

We see three levels of procedures, the lowest or most primitive level, merely cover functions for the native commands in VBA; an intermediate level that implements our logic, and a high level which are macros available to the end-user.

The table below outlines each procedure. The hyperlinks lead to a detailed specification of the procedure.

Level

Name

Arguments

Result

Purpose

Comments

Low

lSaveAs

Document, Fullname

Boolean

Issues a Document.saveAs using the given name.

The calling code is expected to resolve all foreseeable problems with naming, file already exists, name is that of a folder etc. Nonetheless we must trap failure errors caused, perhaps, by unfortunate timing by some other user application.

Low

lClose

Document

Issues a Document.Close (wdDoNotSaveChanges) on the given document

The calling code is expected to have resolved whether or not the document need be saved. If it need be saved, a request to mSaveAs will have preceded the request to mClose.

Low

lFolderExists

Fullname

Boolean

Returns TRUE if the supplied Fullname is that of a folder.

The calling code is expected to pass a structured name. For example, if no drive letter is supplied then the test will be made relative to the current drive.

Low

lFileExists

Fullname

Boolean

Returns TRUE if the supplied Fullname is that of a file.

The calling code is expected to pass a structured name. For example, if no drive letter is supplied then the test will be made relative to the current drive.

Low

lFileOverwrite

Fullname

Long

Solicits a response from the user, returns a unique long value for each of “Yes overwrite this one file”, “Yes overwrite this one file if its date stamp is more recent”, “Yes, overwrite all files”, “Yes overwrite all files if the file’s date stamp is more recent, “No do not overwrite this file”, “No do not overwrite any files” and “Cancel out of the calling procedure”.

The calling code is expected to be judicious in its use of this function.

Medium

mFileSave

Document

Boolean

Uses our logic based on the eight combinations of the Audit, Dirty and Named switches to implement a call to mSaveAs with an appropriate name. returns the cancel status of the latest call to any solicitation procedure.

Medium

mFileSaveAs

Document

Boolean

Uses our logic based on the eight combinations of the Audit, Dirty and Named switches to implement a call to mSaveAs with an appropriate name. returns the cancel status of the latest call to any solicitation procedure. MFileSaveAs must be similar to mFileSave, except that the user wants to offer a file name. The document still suffers the audit/dirty/named considerations but we should avoid the “save-as-original” actioons and replace them with “save-as-solicited” actions for all saves.

Medium

mFileClose

Document

Boolean

Uses our logic based on the eight combinations of the Audit, Dirty and Named switches to implement a call to mClose with an appropriate name. Returns the cancel status of the latest call to any solicitation procedure.

High

FileSave

(None)

(None)

A macro to intercept the user’s request to save a file. Makes a single call to mFileSave.

High

FileClose

(None)

(None)

A macro to intercept the user’s request to save a file. Makes a single call to mFileClose.

High

FileSaveAs

(None)

(None)

A macro to intercept the user’s request to save a file. Makes a single call to mFileSaveAs.

High

FileSaveAll

(None)

(None)

A macro to intercept the user’s request to save a file. Makes repeated calls to mFileSave.

For each open document (except ThisDocument) while mFileSave

High

FileCloseAll

(None)

(None)

A macro to intercept the user’s request to save a file. Makes repeated calls to mFileClose.

For each open document (except ThisDocument) while mFileClose

High

DocumentClose

(None)

(None)

A macro to intercept the user’s request to save a file. Makes a single call to mFileClose.

mFileClose

High

FileExit

(None)

(None)

A macro to intercept the user’s request to close the application. Makes repeated calls to mFileClose.

For each open document (except ThisDocument) while mFileClose;

If Documents.count=0 Application.Quit

A low-level procedure is devoid of all logic.

A high-level procedure (user macro) is almost free of logic.

Only the mid-level procedures hold logic, and they embrace almost all the logic.

There are only three mid-level procedures: mFileSave, mFileSaveAs and mFileClose, and mFileSaveAs differs from mFileSave ONLY in that a full name may be offered through solicitation to the user.

It would be nice to amalgamet mFileSave and mFileSaveAs into a single procedure with an optional switch.

The low-level procedure lFileOverwrite produces multiple values of result, of which some values must be ratined and carried into the next invocation. For example “No, do not overwrite any further files”.

LFileOverwrite being invoked, it must first examine the retained value of a preceding result to determine if the user wishes to inhibit solicitation.

Thus the calling code:

If lFileExists(Fullname) Then

If lFileOverwrite(Fullname) belongs to Overwrite Then

Overwrite the file

Else

Don’t overwrite the file

Else

(Over)Write the file

Thus the code for lOverwrite

If retained value belongs to InhibitSolicitation Then

Return retained value

Else

Return solicited value

A procedure is deemed to have cancelled if

(1) Any invokedprocedure has cancelled

(2) Any user soliictaion results in a cancel

(3) Any irrecoverable error occurs

709-218-7927 CPRGreaves@gmail.com

Bonavista, Saturday, April 27, 2024 8:06 AM

Copyright © 1990-2024 Chris Greaves. All Rights Reserved.