Autosave A Document

Mobile users sometimes complain that they have lost their input data because
their laptop shut down while composing a long Notes document.

This is a LotusScript routine that allows user's to automatically save thier
documents, e-Mail or otherwise.
Step 1 - Add the following definitions to the Declarations:
Dim timeKeeper As Integer
Dim timeClock As NotesTimer
Dim autoSaveInterval As Integer

Step 2 - Paste the following code into the Postopen and PostModeChange events:
Dim session As New NotesSession
Dim autoSaveMinutes As Integer

If Source.EditMode = True Then
AutoSaveOn = session.GetEnvironmentString( "AutoSaveOn"
) ' Is AutoSave turned on in the user's
notes.ini file?
If (AutoSaveOn <> "1") Then
If (AutoSaveOn = "0") Then
Print "AutoSave feature is off"
End If
' AutoSave is not
turned on - Leave
End If

autoSaveValue = session.GetEnvironmentString( "AutoSaveInterval"
) ' What is the AutoSave time increment set to in the
user's notes.ini file
If autoSaveValue = "" Then
autoSaveValue =
' An AutoSave time increment was not found - Use
the default of 30 minutes
End If

autoSaveInterval = Cint( autoSaveValue
) '
Inform the user how frequently his/her doc will be saved
autoSaveMinutes = autoSaveInterval/60
If autoSaveMinutes > 0 Then
Print "AutoSave feature activated for every " & autoSaveMinutes & " minutes..."
Print "AutoSave feature activated"
End If

Set timeClock = New NotesTimer(1, "Elapsed time since opening document")
' Activate the timer
timeKeeper = 0
On Event Alarm From timeClock Call elapsedTimerHandler
End If

Step 3 - Add this new function:
Sub TimeClock(Source As NotesTimer)
On Error Resume Next
timeKeeper = timeKeeper + 1
If timeKeeper = autoSaveInterval
' The AutoSave time increment has been met - Save this doc
Dim Workspace As New NotesUIWorkspace
Dim UIDoc As NotesUIDocument
Set UIDoc = Workspace.CurrentDocument
Call UIDoc.Save
Print "Saving document... "
timeKeeper = 0
End If
End Sub

Step 4 - Paste the following code into an agent or SmartIcon:
REM " Let the user turn AutoSave On or Off?"
AutoSaveVal := @Prompt([OKCANCELCOMBO]; "Change Auto Save Settings"; "Turn
on/off Auto Save?"; ""; "On" : "Off");
@If(AutoSaveVal = "0"; @Return(NULL);
AutoSaveVal = "On"; @Environment( "AutoSaveOn"; "1");
AutoSaveVal = "Off"; @Environment( "AutoSaveOn"; "0");

REM "Let the user set the AutoSave time increment"
ASValue := @Prompt([OKCANCELCOMBO]; "Change Auto Save Settings"; "Select an
Auto Save time interval:):"; "Every 15 minutes"; "Every 5 minutes" : "Every 10
minutes" : "Every 15 minutes" : "Every 20 minutes" : "Every 25 minutes" :
"Every 30 minutes");
@If(ASValue = "0"; @Return(NULL);
ASValue = "Every 5 minutes"; @Environment("AutoSaveInterval"; "300");
ASValue = "Every 10 minutes"; @Environment("AutoSaveInterval"; "600");
ASValue = "Every 15 minutes"; @Environment("AutoSaveInterval"; "900");
ASValue = "Every 20 minutes"; @Environment("AutoSaveInterval"; "1200");
ASValue = "Every 25 minutes"; @Environment("AutoSaveInterval"; "1500");
ASValue = "Every 30 minutes"; @Environment("AutoSaveInterval"; "1800");

NOTE: The timer 'alarm' event triggers every second, and the event code does
nothing 99.9% of the time. Instead, the timer interval should be set equal to
the save interval, so there are no unnecessary executions. You should print
that you're attempting save before actually doing so. Also note that the
attempt to save may cause sudden validation errors to pop up in the middle of

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.