0
我正在使用VBA Access 2010.顯然,excel文件有13個工作表,我只需要從一個工作表中獲取列。而且,如果有一種方法可以跳過列標題,那將會很有幫助。謝謝。如何從Excel文件導入特定工作表?
這裏是我工作的代碼:
stat.Caption = "Import Files"
Me.Refresh
If txtFileSource.Value <> "" Then
Dim strTablename As String
Dim xlsRpt As New Excel.Application
Dim xbookRpt As New Excel.Workbook
Dim iRowCountRpt As Integer
Dim strRangeRpt As String
If cmbData.Value = "My File" Then
Set xbookRpt = Workbooks.Open(txtFileSource.Value)
iRowCountRpt = xbookRpt.Sheets(1).UsedRange.Rows.Count
strRangeRpt = "A1:I" & iRowCountRpt
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "tbl_Account", txtFileSource.Value, True, strRangeRpt
xbookRpt.Close
xlsRpt.Quit
End If
cmbData.Value = "Select File"
txtDestination.Value = ""
txtFileSource.Value = ""
Call DeleteImportErrorTables
Call MsgBox("Import successful!", vbInformation, "Import File")
End If
stat.Caption = "Ready..."
Me.Refresh