How Do I Import An Excel Spreadsheet

How Do I Import An Excel Spreadsheet

In this video you will find the
answer to the question “How do I import an excel spreadsheet into my Access database?”

Option Compare Database

'ERIK LOEBL(713)409-7041

Dim m_strFileName As String

Private Sub btnImport_Click()
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "spreadsheet name", m_strFileName, True
End Sub

Private Sub btnLocateFile_Click()

    Dim varItem As Variant
    Dim strPath As String
    Dim objFilePicker  As FileDialog
    Dim db As Database
    Dim rst As DAO.Recordset
    Dim strUnitNumber As String
    Set db = CurrentDb()
    Set objFilePicker = Application.FileDialog(msoFileDialogFilePicker)
    With objFilePicker
        'Setup file dialog
        .AllowMultiSelect = False
        .ButtonName = "Select"
        .InitialView = msoFileDialogViewList
        .Title = "Select File"
        'add filter for all files
        With .Filters
         .Add "All Files", "*.xlsx"
        End With
        .FilterIndex = 1
        'disply dilog boxe
    End With
    If objFilePicker.SelectedItems.Count > 0 Then
        m_strFileName = objFilePicker.SelectedItems(1)
    End If

End Sub

Click here for the database and the code:
How Do I Import An Excel Spreadsheet

Offsite Related Information:

“Go Fund Me” Page

($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Tags: , ,