VB for importing of Excel 97 files from a static location, when the file name will not change:
The following names would need to be added or changed depending upon your database, but the punctuation would remain:
AccessTableName = The name of the table in your database to which you wish to add the records. FileAndPathName = The full file and path name, including extensions, of the file you wish to import. StartofRange = The first cell in the range of cells to import. EndofRange = The last cell in the range of cells to import. SheetName = The name of the specific worksheet from the Excel spreadsheet to import.
To import Excel 97 files the following code can be used if the entire first worksheet is to be imported and there are no Field Names on the worksheet. If there are Field Names, change the last "0" to "-1": DoCmd.TransferSpreadsheet acImport, 8, "AccessTableName", "FileAndPathName", 0
If you wish to import a specified range from the first worksheet this formula should be used (same conditions apply for field names) DoCmd.TransferSpreadsheet acImport, 8, "AccessTableName", "FileAndPathName", 0, "StartofRange:EndofRange"
For importing from a sheet other than the first, and using a specified range of cells, use this formula (same conditions apply for field names) DoCmd.TransferSpreadsheet acImport, 8, "AccessTableName", "FileAndPathName", 0, "SheetName!StartofRange:EndofRange"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.