Import Objects with VBA

Normally, Tables, Queries or other objects from another database can be imported manually by selecting Import from Get External Data option from File menu. But this can be achieved through VB Code too and this question, HOW TO? is raised in Microsoft Access Users Forums and I thought it is useful to those who look for this solution. Hence, I present the Code here for importing Tables, Queries and Forms separately. The next method imports all Tables from a Source database into the active database except the Microsoft Access System Tables .

Sponsored Links:

Related Topics

Run saved import spec in VBA
Thought this would be easy, but getting error message

Want to run an import spec that imports and appends data from Excel to my Access table. I ran the import process, saved the import spec, naming it "Import-PGI_Data" then, in my VBA for my button:

DoCmd.RunSavedImportExport "Import-PGI_Data"

I keep getting "argument not optional" error.


Importing an Excel file into Access via VBA
I have found a ton of information on how to import an Access table into Excel, but I have come up short when I have been looking for a way to import an Excel file into Access via VBA.

Currently, I have 3 tables that I update monthly manually by means of the Import Wizard, but I am looking to automate the process as much as possible.

At the least, I would like to hit a button in a form that imports a particular Excel file (the name doesn't change from month to month) and at least brings me into the import wizard.

I am just starting out in VBA,


Import from Excel using Import Spec
Is it possible to import a spreadsheet into Access using an import specification? I've created import specifications to successfully import spreadsheets into Access and I would like to automate those imports using VBA. But, I cannot find the 'DoCmd.TransferSpreadsheet' syntax that'll work. I do not want to convert the spreadsheets to .txt or .csv


export secured database
I have a secured database which is giving me some problems at the moment,it might be corrupted or on the verge of corruption.

When I import the objects into a new db the problems get solved except I do not have the ULS of the old database.

Can I import the database objects with current security settings?


Stop users importing objects into another database
I have a split database created entirely in Access. The BE holds all the tables and is password protected, and the FE holds the queries, forms, reports, macros etc. On one of the forms, there is an event procedure on the On Click property of a label which enables/disables the bypass key.

How can I stop a user from simply creating a new database and importing the objects from mine? Although they can't import the tables themselves, they can import the links and see all the data contained in them, and they can import the forms etc.


Stop users importing objects into another database
I have a split database created entirely in Access. The BE holds all the tables and is password protected, and the FE holds the queries, forms, reports, macros etc. On one of the forms,there is an event procedure on the On Click property of a label which enables/disables the bypass key.

How can I stop a user from simply creating a new database and importing the objects from mine? Although they can't import the tables themselves, they can import the links and see all thedata contained in them, and they can import the forms etc.


Change Import/Export directory via VBA
I would like to change the path of a stored import (Excel) via VBA rather than displaying the Manage Data Tasks window to my end-users. I'd like to display a popup allowing them to search for the correct folder, and then I would insert the selected string.

So far I found Application.CurrentProject.ImportExportSpecificati ons.Item but that is read-only and asking for the name of my stored import


Importing objects error
When importing objects from one database (office 2000) to another (Office 2000) in Access 2010, the import wizard keeps running long after the objects have been imported.


Using Left([FieldName],3) to look at the name of a file
Im looking to import a bunch of files to a table all at once using vba.

I want vba to be able to look at the first 3 letters of the file name to identify it. Then take the next 3 and import all the data to a table.

i.e. file name

999APT130410.txt

I want it to look at [999] which is a code linked to a table
import all the data to a table and add [APT] to the table as an identifyer


importing and linking data and database objects
You can import or link data from a variety of supported databases, programs, and file formats.
Learn: Should I import or link a table? What happens when importing data. What happens when linking data. Import and link data from ODBC data sources. Unsupported programs. Automating import operations. Linked table properties. About import/export specifications and schema.ini files.


Importing Data into Microsoft Access using VBA
You might be wondering why you would want to use VBA code to import data while you have so many other options available when doing it the visual way. Well, there are two main reasons:
Importing data through VBA code enables you to work with a variety of formats that is not available when you do it using the visual interface such as delimited text in a text file or data in a word table.
On a more practical level, if you need to make the same import every time, then simply creating a function to do the job for you will make the process faster and easier as opposed to going through the import wizard every time.


Import in Access (2003)
I want to import a txt.file in Access. If I do it manually, everything is OK. But if I want to do it by VBA : DoCmd.TransferText acImportDelim, "ImportSpecificationBasicFile", "BasicFile", GetImportFile(), True
where BasicFile the name is of the file where to import
GetImportFile() the name is of the file to import
then I receive at some places in the table strange characters :for exemple : Pav d'Ath / Rue Flix Bovie / Rosires

It seems that there is a problem with the special french characters : ,
Could it be a prbl with the codepage? and so how can I resolve it and include in this VBA sentence


Requesting values from webpages through VBA
Im trying to request the values of some objects in a couple of webpages, from MS Access through VBA, but I can't find a way to request the value of objects on webpages. Can this be done?
I'm using HyperlinkAddress to call the page, no problems there. But I cant get a hold of the values in the page through VBA.
I've been thinking that I might need to use DDE or something, but I don't think that works with simple html pages and it must be possible to do it through some kind of request in VBA


vba for export and import
First, to export the data in a query to an excel file, overwriting the existing file

and

Second, to import an existing excel file and append it to an existing access table.

If I use the ribbon buttons to do this I get sorts of dialog boxes popping up - is it possible to write vba in which I can specify the various options, so it will do it seamlessly? -Either with or without making use of the Saved Import / Export feature?


Import multiple worksheets
I have a service report in Excel format that is divided into 8 separate worksheets, and I would like to be able to import all of them at the same time into a database I'm developing. Until now I have been doing it manually in the File -> Get External Data -> Import, but this is a very laborious process that has an added risk of operator error. I've seen that it's possible to run a macro that would import worksheets, but in writing the macro Access needs to know the filename ahead of time.

With my service report, all of the worksheets are named to correspond to the tables I want to import into, but the filename will not be consistent. Therefore I believe I'll have to do this in VBA. Although I have VBA experience in Excel, I don't know how to do it in Access. Would someone be able to point me in the right direction


VBA to import selected columns to Access
I receive an Excel file every day with 3 sheets (Removed, StartDt, Scheduling) which I need to import into 3 Access2007 tables with the same names. I want to use a command button to import the data and append the Excel records to the tables.

However:
I do not want to import all of the columns in all of the sheets.
I want to add the filename to each imported record in all 3 tables.
I want to be able to manipulate some of the data as it's imported. For example, if the value in column C of the "Removed" sheet is an "A", I want to import the value "Alpha", if "B" I want to import the value "Beta", etc.

I don't want to have to link the individual sheets each day and use a query. I want to be able to do this with VBA code.

Does anyone have example code that they can share


TransferText VBA Import Issue
I'm trying to a VBA docmd.TransferText statement (properly formatted) to import and append "csv" data to an existing table, e.g.

PHP Code:
DoCmd.TransferTextacImportDelim,"ImportSpecification","tbImportedData",strPathAndFile,vbNo

The VBA code creates a new table with an identical name, while a manual import properly appends the existing table.

Can VBA be used to append an existing table with a TransferText statement


Import Word document using VBA
How is it possible to import a Word document, one line at a time using VBA? I am only interested in the raw text, so converting the file first may be an option. I will need to scan the line / variable for certain key words.


import text into table access
I need to know how to write VBA code to select
the hard disk of the computer file "TXT" and import it into a table
Access 2003 using VBA, without using bees commnon dialog and education TransfertText


Cannot import objects from secured database
I have 2 user-level secured .mdb databases using different workgroup files. The same user (X) belongs to the 2 workgroups. Owner of the first .mdb is set to a different user (Y), and the owner of the second database is set to "Unknown" (which I suppose means that the onwer user has been deleted from the workgroup, right ?).
Now, when user X logs into the first database, he's unable to import objects from second database ("You have not the right permissions. Contact the administrator blah blah").
How can I fix this ? Is this related to ownership ? If yes, how can I change the ownership ? I cannot import to a new UNsecured database cause the same error occurs