Access Import Of Spreadsheet Or Table

I received an email question about the
difference in importing an Access object
versus an Excel spreadsheet.

In this video you are going to
find out how to import your
spreadsheet or table using the
access import feature and vba.

Option Compare Database

'========================================================
'DATABASE DESIGNED & CODED BY LOEBLCOM SERVICES 2013
'ERIK LOEBL(713)409-7041
'EMAIL: erik@loeblcomservices.com
'WEB:   http://loeblcomservices.com
'========================================================

Dim m_strFileName As String

Private Sub btnDBTable_Click()
    DoCmd.TransferDatabase acImport, "Microsoft Access", m_strFileName, acTable, "Customers", "Customers_Local", False
    
End Sub

Private Sub btnImportSS_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
         .Clear
         .Add "All Files", "*.mdb,*.accdb,*.xlsx"
        End With
        .FilterIndex = 1
        'disply dilog boxe
        .Show
    End With
    
    If objFilePicker.SelectedItems.Count > 0 Then
        
        m_strFileName = objFilePicker.SelectedItems(1)
        Me.txtImportFile = m_strFileName
        
    End If


End Sub

Click here for the database and the code:
Access Import Of Spreadsheet Or Table




By the way, if you got or are getting value from the VBA information, please give me a tip, thanks!


These posts may help answer your question too...

How To Parse A Flat File In Excel VBA

In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]

How to pick a file to load In VBA

Picking a file to load in your Microsoft App is a very important skill to know. In this blog post you will see how to do it. First you need to set a reference to the MS office object library From VBE editor –> select Tools > MS office object library (click check mark) Sub […]

How can I interact with other Office applications (Excel) using VBA in Access?

Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]

What Is Microsoft Access Used For?

To those of you who are asking the question of “What is microsoft access used for?” , here is my opinion. I’ve been using this program for well over 15 years, and it’s become fairly easy to deal with. Many people feel that it is hard to work with, but that’s not my experience anymore […]

Previous Post

Shell VBA function

Next Post

How Do I Import An Excel Spreadsheet