Anda di halaman 1dari 2

Private Sub ImportXLSheets()

Dim
Dim
Dim
Set

WrksheetName As String
i As Integer
xl As Object
xl = CreateObject("Excel.Application")

xl.Visible = True
xl.Workbooks.Open "C:\Users\IrvingJosue\Dropbox\CTYOP\Base de Datos Especificaci
ones\Especificaciones\Tablas Finales\T1.xlsm"
With xl
.Visible = True
With .Workbooks(.Workbooks.Count)
For i = 1 To 3
WrksheetName = .Worksheets(i).Name
DoCmd.TransferSpreadsheet (acImport), acSpreadsheetTypeExcel12Xml, WrksheetName,
"C:\Users\IrvingJosue\Dropbox\CTYOP\Base de Datos Especificaciones\Especificaci
ones\Tablas Finales\T1.xlsm", True, WrksheetName & "!"
Next i
End With
End With
Set xl = Nothing
End Sub

Sub sss()
strPath = "C:\Users\IrvingJosue\Dropbox\CTYOP\Base de Datos Especificaciones\Esp
ecificaciones\Tablas Finales\"
Dim xl As Object
Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.DisplayAlerts = False
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strPath)
Dim WrksheetName As String
'Dim i As Integer

For Each objFile In objFolder.Files


If objFso.GetExtensionName(objFile.Path) = "xlsm" And Left(objFile.Name, 2) <> "
~$" Then
'Set objWorkbook = objExcel.Workbooks.Open(objFile.Path)

xl.Workbooks.Open objFile.Path
xl.Visible = True
Dim NN As String

NN = Left(objFile.Name, Len(objFile.Name) - 5)
For i = 1 To 3
If xl.Worksheets(i).Name = "Tubo" Then
WrksheetName = NN & " T"
ElseIf xl.Worksheets(i).Name = "Conexiones" Then
WrksheetName = NN & " C"
ElseIf xl.Worksheets(i).Name = "Accesorios" Then
WrksheetName = NN & " A"
End If
Dim MM As String
MM = xl.Worksheets(i).Name
DoCmd.TransferSpreadsheet (acImport), acSpreadsheetTypeExcel12Xml, WrksheetName,
objFile.Path, True, MM & "!"
Next i
xl.ActiveWorkbook.Close
'Set xl = Nothing
End If
Next
xl.Quit
End Sub

Anda mungkin juga menyukai