Duncan
Here is some of the code:-
Code Start******************************
Option Explicit
Public Function chkDataSource() As Boolean
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(Sheets("Benchmark").Range("DataLocation")) Then
getDataSource
End If
Set fs = Nothing
End Function
Private Sub getDataSource()
Dim strFullPath As String
Dim strXLDirectory As String
Dim strSavedFileName As String
Dim bwrongext As Boolean
On Error GoTo Err_getDataSource
reenter:
If Not getFileName(strFullPath, LOCATE_DATA_TITLE, True, strXLDirectory, _
ACCESS_FILTER, ACCESS_EXTENSION, strSavedFileName,
bwrongext) Then
' The User cancelled, a file was not chosen.
Exit Sub
Else
' Check that the chosen file is our database file
If StrComp(strSavedFileName, "Benchmarker.mdb", vbBinaryCompare) <>
0 Then
If MsgBox("The file you chose is not the correct Database File."
& vbCrLf & _
"Please locate the file 'Benchmarker.mdb'." & vbCrLf &
vbCrLf & _
"Do wish to continue ?", vbCritical + vbYesNo, "Can't
Continue") = vbNo Then
Exit Sub
Else
' Try again
strFullPath = ""
strXLDirectory = ""
strSavedFileName = ""
bwrongext = False
GoTo reenter
End If
If bwrongext Then
MsgBox "The file you chose is not a saved" & vbCrLf & _
"Access Database file." & vbCrLf & vbCrLf & _
"The Data Source could not be Opened", vbExclamation,
"Bad file type"
Exit Sub
End If
End If
End If
MsgBox "The Benchmarker will now be saved to update" & vbCrLf _
& "the new database location.", vbInformation, "Saving Workbook"
ActiveSheet.Unprotect Password:=PWD
ActiveSheet.Range("DataLocation") = strDBName
ActiveSheet.Protect Password:=PWD, DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveWorkbook.Save
Exit_getDataSource:
Exit Sub
Err_getDataSource:
lngErr = Err.Number
strErr = Err.Description
Err.Clear
CentralError "Module basDataSource", "getDataSource() ", strErr, lngErr
Resume Exit_getDataSource
End Sub
Code End ***************
The code bombs out at 'ActiveWorkbook.Save'