Actualizar datos de libros de Excel sin abrirlo
Tengo una macro (CREADA POR DANTE) que me trabaja muy bien sobre lo que necesito, con la misma extraigo los datos de todos los libros que tengo en una carpeta llamada AIM en el disco "E". Desde una hoja que en cada libro se llama RESUMEN (hoja1) todos los archivos son de extensión .xlsm
Estos registros se guardan en una hoja llamada totales de un libro que esta en el disco "C".
Estos registros los usos para manejar el calculo de intereses que se aumentan cada día. Hoy me he dado cuenta que si no he abierto eses libro en varios días me esta tomando el dato que existe hasta el día que lo abrí por ultima vez, se actualiza cuando lo abro.
Existe una forma de actualizar los libros sin abrirlos. Vi una macro de VALEDOR74 que creo en el 2013 que si los actualiza, pero no se como ajustar esta macro a este procedimiento, por tanto solicito ayuda de un experto.
Sub TOTALES_ACTUALIZAR_CUADRE()
'Por.Dante Amor
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ruta = "E:\AIM\" 'Poner el nombre de la carpeta con los 600 libros
hoja = "TOTALES" 'Nombre de la hoja donde se acumularán los totales
'ESTO MUEVE LAS COLUMNAS A LA DERECHA
arch = Dir(ruta & "*.xlsm*")
j = 27
Set h = Sheets(hoja)
' h.Cells.ClearContents
On Error Resume Next
Do While arch <> ""
h.Cells(1, j).Value = arch
'ESTA PARTE LEE EL CAPITAL ADEUDADO
h.Cells(2, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e9,""No existe la hoja"")"
h.Cells(2, j).Value = h.Cells(2, j).Value
h.Cells(3, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e10,""No existe la hoja"")"
h.Cells(3, j).Value = h.Cells(3, j).Value
h.Cells(4, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e11,""No existe la hoja"")"
h.Cells(4, j).Value = h.Cells(4, j).Value
h.Cells(5, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e12,""No existe la hoja"")"
h.Cells(5, j).Value = h.Cells(5, j).Value
h.Cells(6, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e13,""No existe la hoja"")"
h.Cells(6, j).Value = h.Cells(6, j).Value
h.Cells(7, j).Formula = "=IFERROR('" & ruta & "[" & arch & "]resumen'!e14,""No existe la hoja"")"
h.Cells(7, j).Value = h.Cells(7, j).Value
j = j + 1
arch = Dir()
Loop
Application.ScreenUpdating = True
MsgBox "PROCESO REALIZADO"
End Sub
ESTA ES LA MACRO DE "VALODOR74"
Sub ActualizaInventario()
Dim lngNumReg As Long
Dim strRuta As String
Dim wbHistorial As Workbook
Dim wbActual As Workbook
'Desactivamos la actualización en pantalla, esto acelera
'bastante la ejecucií²n del código
Application.ScreenUpdating = False
'Establecemos la ruta del archivo Historial, por supuesto
'puede estar en cualquier parte del disco o incluso de la red
strRuta = ThisWorkbook.Path & "E:\AIM\*.xlsm"
'Verificamos que exista el archivo Historial
If Existe(strRuta) Then
'Guardamos la referencia al libro actual
Set wbActual = ThisWorkbook
'Abrimos y establecemos una referencia al libro Historial
Set wbHistorial = Workbooks.Open(strRuta)
'nos aseguarmos que este oculta la ventana del libro Historial, de esta manera no lo ve el usuario
wbHistorial.Windows(1).Visible = False
'Al abrir un libro, aunque sea por código, este queda activo
'activamos el libro anterior de donde se copiaran los registros
WbActual. Activate
'aquí puedes poner el código que quiera para manipular el archivo historial o tu base de datos
'AL TERMINAR
'Guardamos el libro Historial
WbHistorial. Sabe
'Cerramos el libro Historial
WbHistorial. Close
'Liberamos la memoria usada
Set wbHistorial = Nothing
Set wbActual = Nothing
DoEvents
Else
'Si no se encontro el archivo Historial, solo borramos
'los datos filtrados
MsgBox "No se movieron datos por que el archivo Historial no existe"
End If
'Reactivamos la actualización de pantalla
Application.ScreenUpdating = True
End Sub