Executing Import Wizard via code

alex_hatzisavas

Registered User.
Local time
Today, 01:33
Joined
May 18, 2006
Messages
12
Hi all.

I'm trying to enhance the functionality of an MS Access application.

I want to give the user the capability to import a MS Access or MS Excel
table into the application *without* having to execute the Import Wizard
herself.

Q1:
So i'm basically looking for the VBA statement that will invoke the Import
Wizard (the equivalent of right-clicking in Tables view and choosing: Import).

Q2:
Is there a way to capture the name of the table that's being imported?
I will need to append it to another one once the user has imported it.

If not, i was thinking to simply capture all the table names before the user
starts the Import Wizard and after he's done so, so the difference would give
me the name of the newly imported table.

Many thanks for your help,
Alex
 
Q1: As for any built-in menu option the docmd.RunCommand(acCmdImport) wil do what you request

Q2: For what I know the docmd function doesn't return a value.
 
Importing a table

Almost certainly not what you are after - but we use the following code to regularly import from an excel spreadsheet:

Private Sub btnUpload_Click()
Dim msgret As String
Dim strdir As String
msgret = MsgBox("Are you sure you want to Upload the File?", vbYesNo)
If msgret = "6" Then
strdir = "Z:\Database\"
DoCmd.SetWarnings False
DoCmd.OpenQuery "Delete Original"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "Original", strdir & "File.xls", -1
DoCmd.SetWarnings True
MsgBox "File Uploaded", vbInformation
Me.Refresh
Else
DoCmd.Beep
End If
End Sub

(edited slightly)
 

Users who are viewing this thread

Back
Top Bottom