2014-02-10 3 views
0

엑셀 파일의 데이터를 액세스로 가져 오는 다음 매크로를 작성했습니다. 그러나 내가 가져 오는 데이터는 (때로는 A1 : B2, 때로는 A1 : B5 등 ...) 요동 치기 때문에 모든 관련 데이터를 선택하는 것이 이상적입니다. 엑셀에서 데이터를 가져 오기

누구에게 ... 내가 이것을 달성 할 수있는 방법에 대한 아이디어를 액세스에

  • A1 셀을 선택
  • XLtoRight
  • XLDown
  • 복사이 : 그래서 뭔가를해야합니까?

    Sub ImportExcel() 
    
        Set ExcelApp = CreateObject("Excel.Application") 
        Set ExcelWb = ExcelApp.Workbooks.Open("C:\Documents and  Settings\aa471714\Desktop\Book1.xls") 
        ExcelApp.Visible = True 
    
        DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, "Gegevens", "C:\Documents and Settings\aa471714\Desktop\Book1.xls", True, "A1:B5" 
    
        With ExcelApp 
    
        .Quit 
    
        End With 
    
        MsgBox ("De gegevens zijn ingelezen") 
    
    End Sub 
    
+0

한 가지 제안이 여기에 포함됩니다 : http://stackoverflow.com/questions/15930832/import-dynamic-and-static-ranges-from-excel-in-to-ms-access-that -do-not-start-at –

답변

0

Range은 선택적 매개 변수입니다. 건너 뛰어 전체 워크 시트를 가져 오십시오. 동적 범위를 다시

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, "Gegevens", "C:\Documents and Settings\aa471714\Desktop\Book1.xls", True 
관련 문제