1. Creamos un formulario en Access
2. Creamos un botón de formulario
3. Al momento de tener el botón seleccionamos el botón y damos click derecho y seleccionamos propiedades.
4. Se abrirá un menú y nos colocaremos en la pestaña de formato y en donde dice titulo escribiremos Importar Datos Excel, después nos vamos a la pestaña eventos.
5. En la pestaña eventos en la opción de al hacer click selecionamos PROCEDIMIENTO DE EVENTO, damos click y se abrirá Visual basic.
6. En el programa visual basic introduciremos el siguiente comando:
Private Sub ImportarDatosDeExcel_Click()
Call fimportAllFiles
End Sub
7. Despues que introducimos el código del paso 6, a continuación introduciremos el código principal:
Function fimportAllFiles()
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String
Dim blnHasFieldNames As Boolean
‘ Change this next line to True if the first row in EXCEL worksheet
‘ has field names
blnHasFieldNames = False
‘ Replace C:\Documents\ with the real path to the folder that
‘ contains the EXCEL files
strPath = «C:\DeltaServerConvertidos\»
‘ Replace tablename with the real name of the table into which
‘ the data are to be imported
strTable = «llamadas»
strFile = Dir(strPath & «*.xls»)
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, strTable, strPathFile, blnHasFieldNames
‘ Uncomment out the next code step if you want to delete the
‘ EXCEL file after it’s been imported
‘ Kill strPathFile
strFile = Dir()
Loop
MsgBox «Done»
End Function
8. Para finalizar nos regresamos a Access y oprimimos el botón que creamos para correr el programa que creamos en Visual Basic.