Function BuscaCarpeta(FNAme As Form, Optional RutaInicial As String, Optional RutaAntigua As String, _
Optional Formulario As String, Optional Campo As String) As String
On Error GoTo err_lbl
Dim fDialog As Office.FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.AllowMultiSelect = False
.ButtonName = "Seleccionar"
.Title = NombreBD
.InitialFileName = Ruta
.InitialView = msoFileDialogViewDetails
.Filters.Clear
If .Show = True Then
BuscaCarpeta = .SelectedItems(1)
If RutaInicial = GetDBPath Then Exit Function
If RutaInicial <> "" Then
CopiarArchivos RutaInicial, BuscaCarpeta
End If
Else
' MsgBox "Has cancelado la selección de la carpeta.", vbInformation, NombreBD
If Not RutaAntigua = "0" Then
BuscaCarpeta = RutaAntigua
End If
If Not Formulario = "" Then Forms(Formulario).Controls(Campo) = 0
Select Case FNAme.ActiveControl.Name
Case "RutaCarpeta"
DespuesDeActualizarLaRutaDeCarpeta
Case "CopiaDeSeguridad"
DespuesDeActualizarCopiaDeSeguridad
End Select
Exit Function
End If
End With
Salida:
Exit Function
err_lbl:
MsgBox "BuscaCarpeta: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
Resume Salida
End Function