Link to home
Start Free TrialLog in
Avatar of drtopserv
drtopservFlag for Israel

asked on

Import excel files xls/xlsx/xlsm into access by vba code

Hi,
I`d like to import excel extentionS into table in access i have the code to do that.
the issue is that the code import the file/files with row contain null/empty value.
how may i discard importing empty rows?
In out way : if all the row is empty/null don`t import it .
Avatar of ukerandi
ukerandi
Flag of United Kingdom of Great Britain and Northern Ireland image

DoCmd.TransferSpreadsheet  acImport,acSpreadsheetTypeExcel12Xml, "Table1", "C:\Winxp\testing.xls", True, "" 
DoCmd.TransferSpreadsheet  acImport,"", "Table1", "C:\Winxp\testing.xls", True, "" 
Avatar of drtopserv

ASKER

Yes it works :} thnxx:}
but what that  "" Means? in the range
after acImport is Excel spreadsheet type, for example Excel 2003 or Excel 2010 or xml type
like
acSpreadsheetTypeExcel12Xml
acSpreadsheetTypeExcel12

after true "" is Range
A1:B3



more explain Range

A string expression that's a valid range of cells or the name of a range in the spreadsheet. This argument applies only to importing. Leave this argument blank to import the entire spreadsheet. When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.
still can`t follow,
if i came to import the excel without writing "" i`ll get all the sheet include empty rows.
which parameter that tell that u wanna import only cells cotains data without empty rows?
ASKER CERTIFIED SOLUTION
Avatar of ukerandi
ukerandi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
does ur code work work in access vba?
no, you need to run first run above macro in Excel
Avatar of Norie
Norie

There is no setting that will stop blank rows/records being imported.

Why not run a delete query after the import to delete the blank rows/records?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
before run need to enabled security settings
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thnx,ur code help me out "}