Solved

Convert .xls to .mdb

Posted on 2009-07-01
3
853 Views
Last Modified: 2012-05-07
Hi Experts,
  Anyway we can convert .xls file to .mdbfile ?
0
Comment
Question by:mkdev2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
Eirman earned 250 total points
ID: 24752959
Assuming you have access ... File > Get external Data > Import ... Then choose "Files of type" XLS
0
 
LVL 3

Assisted Solution

by:Michal-Drozd
Michal-Drozd earned 250 total points
ID: 24753562
Here is one of soultions:
Create the access application object. Open a database (or create new one).
After that you can execute any you want that you can normally do from code in access

Dim oApp As Object
Set oApp = CreateObject("Access.Application")
oApp.Visible= True ' if you want to see it

read up on the following:
OpenDatabase (dbname, options, read-only, connect)

look at:
TransferText(TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)
more about this function you find here: http://www.blueclaw-db.com/transfertext-docmd.htm

or better this function (xls to mdb) something like this:
docmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "TMP_TABLE", "c:\my_file.xls", true, "WorksheetName"

Change the True to False if the first row does not contain column headings
example, like so with oApp:
oApp.DoCmd.TransferText( .....enter args)

don't forget when done to:
oApp.quit
Set oApp = Nothing

small example:
Private Sub cmdImport_Click()
Dim strFileName As String ' filename we are importing from
 
'get filename from user to import
If strFileName = "" Then
With ComDlg
.CancelError = True
.Filter = "XLS Files (*.xls)|*.xls" _
& "|All Files (*.*)|*.*"
.DefaultExt = ".ext"
.DialogTitle = "Select File"
.FilterIndex = 1
'.InitDir = "default directory goes here"
.Flags = cdlOFNHideReadOnly
.ShowOpen
If .FileName <> "" Then strFileName = .FileName
End With
End If
 
'do import of file
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "ImportTable", strFileName, True, "ImportArea"
Exit_cmdImport_Click:
Exit Sub

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question