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
'========================================================
'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 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
.Clear
.Add "All Files", "*.xlsx"
End With
.FilterIndex = 1
'disply dilog boxe
.Show
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
How to Fix Run Time Error 1004 in Excel
If you work with Microsoft Excel frequently, chances ar ling for a solution. Fortunately, this error is well-documented, and there are several ways to resolve it. In this article, we’ll explore the causes of run time error 1004, practical steps to fix it, and preventive measures to reduce the chances of it happening again. What […]
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
How to Pick a File in VBA: FileDialog & GetOpenFilename Explained When building Excel VBA applications, you’ll often need to let users pick a file to load in VBA. Instead of hard-coding file paths, you can use built-in dialogs that make file selection easy and user-friendly. VBA offers two main approaches: FileDialog object (flexible, customizable) […]
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 […]
Support these sponsors:
