jueves, 27 de octubre de 2016

Eliminar los archivos recientes con VBA - Excel Macro:

1. Presione ALT + F11 (se abrirá la ventana… Microsoft Visual Basic for Applications)
2. Inserte un módulo (clic derecho sobre algún elemento del Proyecto), y pegue el siguiente código.
Sub BorrarMisExcelsRecientes()
Dim i As Integer, thedlls As String, therecenname As String, GetYisusRecentfilefullPath As String, LAstPArtedeCadena() As String, cadenaFinalFullName As String
'lista de archivos a borrar unidos a \ separador de ruta
thedlls = "\libro1.xls\l2.xls\libro3.xls"
For i = 1 To Application.RecentFiles.Count
GetYisusRecentfilefullPath = Application.RecentFiles.Item(i).Name
LAstPArtedeCadena = Split(Application.RecentFiles.Item(i).Name, "\")
'obtengo el ultimo del array
cadenaFinalFullName = LAstPArtedeCadena(UBound(LAstPArtedeCadena))
'Comparo si hay coincidencia
If InStr(GetYisusRecentfilefullPath, cadenaFinalFullName) > 0 Then
Application.RecentFiles.Item(i).Delete
End If
Next
End Sub



No hay comentarios: