Importing Excel into Access

New_Kid_in_Block

New member
Local time
Tomorrow, 03:19
Joined
Mar 19, 2009
Messages
2
Hi
I am a new bie with Access07. I work in an Oil and Gas services company and have no back groud in programming or database design. :(
I wanted to design the VBA code for importing an Excel Sheet into Access.
I have defined the table (with required columns and properties).
Basically the VBA code should do the following.
1) Open a pop up(when clicked button on form) which I can use to select the file I want to import(just like when we click the open button on Word and user can navigate where his/her file is stored onto disk)
2) Then the rest importing steps should be automated – that is regarding selecting the “Table” where I want to import the file, selecting the work sheet to be used for importing and using first column for table header.
Can someone please help me write this code as I am desperately running against time to submit this project.:((
Will be extremely greatful for the help/ suggestions.:)
Thanks and Regards,
Prashant Kumar.
 
I think everything you want to do should be possible to do.

What parts are you having trouble with?

See:
Import Data from Microsoft Excel
This example is very close to what you want. It should a large part of what you need.
 
Heres a piece of code it put together recently to import delimited txt files into an access database.

you basically hit your button, it brings up a file open dialog box, select the file you want and it will import into your table. Hope it helps


Private Sub Command2_Click()

Dim filename As String

'Opens dialog box for file selection
Set ObjFSO = CreateObject("UserAccounts.CommonDialog")
'Sets Type of file to look for
ObjFSO.Filter = "VBScripts|*.vbs|Text Documents|*.txt|All Files|*.*"
ObjFSO.FilterIndex = 3
Sets Directory for initial search to start in
ObjFSO.InitialDir = "C:\Your Location"
InitFSO = ObjFSO.ShowOpen

'Transfers file using acImportDelim profile previously set through manually importing into table
DoCmd.TransferText acImportDelim, ("Profile"), ("Temp_Tbl"), filename

End Sub
 

Users who are viewing this thread

Back
Top Bottom