Importing MS Excel sheet into MS Access via VBA not importing everything -
i have ms access database program brings in data ms excel workbook (it's 1 sheet) processed , kicks out completed form user.
the whole thing working fine, when encountered error in report went work database program find problem , new 1 cropped up. ms access importing cells a1 , a2.
when try manually import excel file , append table, import wizard shows 2 cells being included in file. somehow, ms access not seeing entire sheet of data.
i have tried manually changing acspreadsheettype option in docmd.transferspreadsheet , worked once. have tried changing programmatically no effect (i.e., still cells a1 , a2).
here segment of vba deals part of program:
dim acspreadsheettype integer strfile2import = txtfindfile acspreadsheettype = excelversion(strfile2import) docmd.hourglass (hourglasson) docmd.setwarnings (warningsoff) docmd.runsql _ "delete tbl_work_plan_item_import.*, * " & _ "from tbl_work_plan_item_import;" docmd.transferspreadsheet _ acimport, acspreadsheettype, "tbl_work_plan_item_import", strfile2import, true
and here "excelversion" function:
public function excelversion(byval strfile2import string) 'https://msdn.microsoft.com/en-us/library/office/ff840717.aspx 'https://msdn.microsoft.com/en-us/library/office/ff198017.aspx set objapp = createobject("excel.application") objapp.visible = true set wb = objapp.workbooks.open(strfile2import, true, false) excelversion = wb.fileformat wb.close objapp.quit set objapp = nothing select case excelversion case 29 'xlexcel3 (excel3) excelversion = 0 'acspreadsheettypeexcel3 (microsoft excel 3.0 format) case 33 'xlexcel4 (excel4) excelversion = 6 'acspreadsheettypeexcel4 (microsoft excel 4.0 format) case 39 'xlexcel5 (excel5) 'xlexcel7 (excel7) excelversion = 5 'acspreadsheettypeexcel5 (microsoft excel 5.0 format) 'acspreadsheettypeexcel7 (microsoft excel 95 format) case 46 'xlxmlspreadsheet (xml spreadsheet) excelversion = 10 'acspreadsheettypeexcel12xml (microsoft excel 2010 xml format) case 50, 51 'xlexcel12 (excel12) 'xlworkbookdefault (workbook default) excelversion = 9 'acspreadsheettypeexcel12 (microsoft excel 2010 format) case 56 'xlexcel8 (excel8) excelversion = 8 'acspreadsheettypeexcel8 (microsoft excel 97 format) 'acspreadsheettypeexcel9 (microsoft excel 2000 format) end select end function
"strfile2import" , "txtfindfile" file name , full path imported gotten file dialog box.
my original program didn't have excelversion function , had hardcoded acspreadsheettype "acspreadsheettypeexcel12xml" , when changed "acspreadsheettypeexcel9" worked correctly once.
what missing?
for record, have tried doing .recalc , .requery entire form after performing import, , unsuccessful well.
any guys can throw way appreciated!
"delete tbl_work_plan_item_import.*, * " & _
this has * twice.
change
"delete tbl_work_plan_item_import.* " & _
Comments
Post a Comment