Version 2.2 Updated 10 Jan 2021 Approx 0.8 MB
I originally wrote the attached utility in response to a question about editing external files from Access by Access World Forums member smig in this thread:
Editing an external text file - is it possible?
I would like to thank fellow AWF members jdraw & the DBGuy for prompting me with starter code.
Thanks also to smig for suggesting a procedure that I adapted.
Prior to Access 2010, import/export (IMEX) specifications were saved in 2 system tables : MSysIMEXSpecs / MSysIMEXColumns.
This system was replaced with a wizard driven & arguably more powerful XML based system of Import/Export Data Tasks in Access 2010. However, ease of use has also led to greater obscurity in how it works.
For example, the contents of a saved Data Task cannot easily be viewed or edited.
This is an example of the XML for an Import task:
<?xml version="1.0" encoding="utf-8" ?>
<ImportExportSpecification Path = "G:\MyFiles\ExampleDatabases\IMEXSpecifications\Test.txt"
xmlns="urn:www.microsoft.com/office/access/imexspec">
<ImportText TextFormat="Delimited" FirstRowHasNames="false" FieldDelimiter=","
TextDelimiter="" CodePage="850" Destination="Test" >
<DateFormat DateOrder="DMY" DateDelimiter="/" TimeDelimiter=":"
FourYearDates="true" DatesLeadingZeros="false" />
<NumberFormat DecimalSymbol="." />
<Columns PrimaryKey="{Auto}">
<Column Name="Col1" FieldName="Field1" Indexed="NO" SkipColumn="false"
DataType="Text" Width="84" />
</Columns>
</ImportText>
</ImportExportSpecification>
The Access help file contains the following information:
Click the image to view a larger version
The attached example database includes a module modIMEX containing code to do all of the following:
• View Import Export Specifications - this saves all data task specifications to a user defined
system table (normally hidden) called USysIMEXSpecs
• Execute Data Task / Run Data Task – two different ways of running a task using VBA
• Edit Data Task – replace a specified section of the XML with different text string
• Modify Data Task Path – replace the existing path of the external file with a new path
NOTE: you do NOT need to know the existing path to use this
• Modify Data Task Destination – replace the existing destination table for an import task with
a new table name. Once again the existing value is NOT needed
• Rename Data Task – ‘does what it says on the tin’
• Delete Data Task – delete an existing data task using VBA
The example database has 2 import & 2 export data tasks for use with a sample text file test.txt
Store this text file (supplied) in the same folder as the sample database or any folder of your choice.
However, the four IMEX tasks will not run unless your database path is the same as mine – VERY UNLIKELY!
You should easily be able to edit the XML using the above procedures to make these work for you.
All these procedures can be run from the main form
Click the image to view a larger version
Return to Example Databases Page
Return to Top