Boa Noite Senhores !
Achei um exemplo neste site
http://www.accessmvp.com/kdsnell/EXCEL_Import.htm
E estou tentando adptar a minha realidade.
o Codigo funciona perfeitamente como esperado mas preciso fazer alguma alterações do tipo,
Preciso especificar o Range e o Sheet a ser importado.
Private Sub Comando2_Click()
Dim strPathFile As String, strFile As String, strPath As String
Dim blnHasFieldNames As Boolean
Dim intWorksheets As Integer
Dim strWorksheets(1 To 1) As String
' Replace 3 with the number of worksheets to be imported
' from each EXCEL file (this code assumes that each worksheet
' with the same name is being imported into a separate table
' for that specific worksheet name)
Dim strTables(1 To 1) As String
' Replace generic worksheet names with the real worksheet names;
' add / delete code lines so that there is one code line for
' each worksheet that is to be imported from each workbook file
strWorksheets(1) = "sousa"
' Replace generic table names with the real table names
strTables(1) = "TblTeste"
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "C:\dados\"
' Replace 3 with the number of worksheets to be imported
' from each EXCEL file
For intWorksheets = 1 To 1
strFile = Dir(strPath & "teste.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, strTables(intWorksheets), _
strPathFile, blnHasFieldNames, _
strWorksheets(intWorksheets) & "$"
strFile = Dir()
Loop
Next intWorksheets
End Sub
A Parte onde estar de vermelho tentei alterar de acordo com um exemplo do Meste JPaulo !
http://dl.dropboxusercontent.com/u/771097/ImportarExcelParaAccess.txt
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTabela, "C:\temp.xls", True, bbb.Name & "!A1:AQ500"
Mas não funfou.
Alguma Sugestão ?
Saudacoes !
Achei um exemplo neste site
http://www.accessmvp.com/kdsnell/EXCEL_Import.htm
E estou tentando adptar a minha realidade.
o Codigo funciona perfeitamente como esperado mas preciso fazer alguma alterações do tipo,
Preciso especificar o Range e o Sheet a ser importado.
Private Sub Comando2_Click()
Dim strPathFile As String, strFile As String, strPath As String
Dim blnHasFieldNames As Boolean
Dim intWorksheets As Integer
Dim strWorksheets(1 To 1) As String
' Replace 3 with the number of worksheets to be imported
' from each EXCEL file (this code assumes that each worksheet
' with the same name is being imported into a separate table
' for that specific worksheet name)
Dim strTables(1 To 1) As String
' Replace generic worksheet names with the real worksheet names;
' add / delete code lines so that there is one code line for
' each worksheet that is to be imported from each workbook file
strWorksheets(1) = "sousa"
' Replace generic table names with the real table names
strTables(1) = "TblTeste"
' Change this next line to True if the first row in EXCEL worksheet
' has field names
blnHasFieldNames = True
' Replace C:\Documents\ with the real path to the folder that
' contains the EXCEL files
strPath = "C:\dados\"
' Replace 3 with the number of worksheets to be imported
' from each EXCEL file
For intWorksheets = 1 To 1
strFile = Dir(strPath & "teste.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, strTables(intWorksheets), _
strPathFile, blnHasFieldNames, _
strWorksheets(intWorksheets) & "$"
strFile = Dir()
Loop
Next intWorksheets
End Sub
A Parte onde estar de vermelho tentei alterar de acordo com um exemplo do Meste JPaulo !
http://dl.dropboxusercontent.com/u/771097/ImportarExcelParaAccess.txt
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTabela, "C:\temp.xls", True, bbb.Name & "!A1:AQ500"
Mas não funfou.
Alguma Sugestão ?
Saudacoes !