Auto Recover Object Example

The following subroutine and function sets AutoRecover properties, then ensures that the workbook the code is in uses them:

Sub SetAutoRecoverOptions()

'Set the AutoRecover options for the application

ChangeAutoRecoverSettings True, "C:\Backup Files\AutoRecover\Excel", 2 'Make sure this workbook uses them

ThisWorkbook.EnableAutoRecover = True End Sub

Function ChangeAutoRecoverSettings(Optional ByVal vEnable As Variant, _ Optional ByVal vPath As Variant, Optional ByVal vTime As Variant) 'Only set the property if a value was passed With Application.AutoRecover

If Not IsMissing(vEnable) Then 'Enable AutoRecover .Enabled = vEnable End If

'Only set the property if a value was passed If Not IsMissing(vPath) Then

'Change the path to a central backup files area .Path = vPath End If

'Only set the property if a value was passed If Not IsMissing(vTime) Then

'Save every AutoRecover file every 2 minutes .Time = vTime End If End With End Function

0 0

Post a comment