Access 2003: Import Extensionless Files

B

Brig Siton

Using Access 2003:

Trying to import files with no extensions.

I added .txt on the filename to be able to import the file.

When I do it manually: File > Get External Data > Import, I am able to
import the data with no problems.

However, when I create a macro, TransferText, Import Fixed Width and pointed
to where the file is, I get the following messge:

----------------------------
You can not import this file.

You cannot import a text file unless it has one of these extensions: TXT,
CSV, TAB, ASC, TMP, HTM, HTML.
----------------------------

Any advise?

Thank you very much in advance.

Brig Siton
 
A

Arvin Meyer [MVP]

Instead of using a macro, use VBA code. Find the file, add .txt to it, then
import the file using your macro.

So, use a subroutine something like this:

Sub Whatever()
Name "C:\FolderName\FileName" As "C:\FolderName\FileName.txt"
DoCmd.RunMacro "MacroName"
End Sub

or better than RunMacro, do the TransferText in code as well

Sub Whatever()
Name "C:\FolderName\FileName" As ""C:\FolderName\FileName.txt"
DoCmd.TransferText acImportDelim, "YourInportSpec", _
"TableName", "C:\FolderName\FileName.txt"
End Sub
 
B

Brig Siton

Great!

Thank you very much.

Brig


Arvin Meyer said:
Instead of using a macro, use VBA code. Find the file, add .txt to it,
then import the file using your macro.

So, use a subroutine something like this:

Sub Whatever()
Name "C:\FolderName\FileName" As "C:\FolderName\FileName.txt"
DoCmd.RunMacro "MacroName"
End Sub

or better than RunMacro, do the TransferText in code as well

Sub Whatever()
Name "C:\FolderName\FileName" As ""C:\FolderName\FileName.txt"
DoCmd.TransferText acImportDelim, "YourInportSpec", _
"TableName", "C:\FolderName\FileName.txt"
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top