Selecting and Importing Excel File and Sheet for import into Access
DRANK

IntroductionA common requirement in Microsoft Accessis the ability to import files. Compared to working with C# and Visual Basic.Net, this is somewhat different.ImplementationThe first requirement is to be able to browse to the Excel file. Here is the code that is executed in the form when the “Browse” button is clicked:Private Sub buttonBrowse_Click() Dim itemsString As String textBoxExcelFileToImport = "" listBoxWorksheets.RowSource = "" subFormData.Visible = False DoEvents textBoxExcelFileToImport = GetExcelFile If IsNull(textBoxExcelFileToImport) Then Exit Sub itemsString = Join(ExcelSheetsNameList(textBoxExcelFileToImport), ";") listBoxWorksheets.RowSource = itemsString End SubThis code first clears out information in the form that may be applicable to the last file that was selected, and then the user is provided a dialog to select a file with the “xlsx” extension. If a file is not selected, then the code returns, ot…

codeproject.com
Related Topics: Excel Microsoft Access C#