Print Out # Templates On A Server By Subdirectory

For design refresh purposes its convenient to use the .nsf format to save Notes
Templates. However, in a heavy development environment there may be too many
templates or duplicate names in a server directory, thereby complicating design
refresh. This script will allow you to quickly identify the culprits by
Just put this in a button.

Sub Click(Source As Button)
This script returns the title of each template on a server. All results are
stored in a Word 97 file (My Documents\TemplateList.doc). 'Error' results are
also stored in a Word 97 file called
(My Documents\TemplateListError.doc). Both Word 97 files are sent to the
user's default printer, and are made visible to the user at the end of the

Author: David E Bradshaw
Last Edit: 5/13/99

Messagebox "This script will return all templates housed on a particular
Server, by desired subdirectory. The results will be sent to a Word 97 file"&_
" called 'C:\My Documents\TemplateList.doc', while any 'ERROR' results
will be sent to a Word 97 file called 'C:\My Documents\TemplateListError.doc'.
" &_
"Please go to these files to view results.", 64, "Template Search Results"

On Error Goto ExecuteFail

Dim s As New NotesSession
Dim db As NotesDatabase
Dim directory As NotesDbDirectory
Dim servername$
Dim templatename$
Dim desPath$
Dim corrPath$
Dim adjPath$
Dim pathCnt%

Set directory = s.GetDbDirectory(Ucase(Inputbox("Please Enter Server
Name. Leave blank for Local.")))
desPath$ =Ucase(Inputbox("Please Enter Desired Directory (eg
pathCnt% = Len(desPath$)

'check for an available file number to use. If none exists then assign
the next available one for use in
' creating/opening the desired filename. If a number is already in use
then, close it.

If Not fileNum%>0 Then
fileNum% = Freefile()
Close filenum%
End If
Open "c:\My Documents\TemplateList.doc" For Output As fileNum%

Set db = directory.GetFirstDatabase( DATABASE ) 'only look for the '.nsf'
x=0 'initialize counter
y=0 'initialize count for dbs in desired path
Print #fileNum%,("TEMPLATES HOUSED ON SERVER " & servername$ & " -
DIRECTORY: "&desPath$&Chr(13))
Print #fileNum%,("Templates by Number per below: "&Chr(13))
Print #fileNum%,(Chr(13))
Do While Not (db Is Nothing )

templatename$= db.TemplateName ' will only respond if the .nsf is in
fact a template
corrPath$ =Ucase(db.FilePath) ' get the full file path of the database
adjPath$ = Ucase(Left(corrPath$,pathCnt%)) ' adjust the path to the
# of characters entered in desired subdirectory for comparison
' If Left$(templatename$,3) ="NTF" And (desPath$=adjPath$) Then 'look
only for those templates beginning with "NTF" and located in desired
If (desPath$=adjPath$) Then 'look only for those templates located
in desired subdirectory
'Loop through the SERVER and record the name of the templates in the Word
97 file

If db.IsOpen Then
Print #fileNum%,("# " & y & " - "&templatename$ &" - "
&db.FilePath &Chr (13))
Call db.Open("","")
Print #fileNum%,("# " & y & " - "&templatename$ &" - "
&db.FilePath &Chr (13))

End If
End If

x=x+1 'keep a running count of the templates found.
Set db = directory.GetNextDatabase

Print #filenum%,(Chr(13))
Print #fileNum%,("There were " & y & " templates found in " &servername$ &
"\" & desPath )
Print #fileNum%,("There were a total of " & x & " templates found on
server " & servername$ )
Close fileNum% 'close the file number
Close fileNum2% 'close the file number after all error results have been
written to the Word 97 error results

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.