Export Problem

aziz rasul

Active member
Local time
Today, 14:13
Joined
Jun 26, 2000
Messages
1,935
I am importing many xls files and exporting them to the same directory (and same filename as the xls file) as text files. I then, using the Name command, change the extension of the text files to "dat". I then import the next xls file etc.

If I now import the same xls files and re-export and change the extension to "dat" I get an error since the same filename with the same dat extension already exists. How do I first check whether the dat file exists. I know that I need to use the Kill command to delete the file.
 
Include the extension in your output to command to automatically give the file a .dat extension.

DoCmd.OutputTo acOutputTable, "tablename", acFormatTXT, "C:\Test.dat", True
 
That doesn't work Fornation due to a "security" change made to Jet a few years ago. Unless you are willing to modify the registry (you can find directions in a kb article), Jet won't let you read or write a file unles it has one of several specific extensions and .dat is not in the approved list.
 
That's funny pat, I don't think I've put any kb patches on my db and it seems to work OK (pity about the rest of my PC though! :) ), Windows 98 SE & Access97. Just realised Access 97 is 'a few years ago' still going strong mind.
 
It works in Access 97 but not in Access 2000 which is what I am using.
 
Use:

If Dir("PathToFile")<>"" then 'file exists
Kill "PathToFile"
End if
'carry on...
 
It was so simple. When I try too hard I find it difficult to think straight.

Many Thanks.
 

Users who are viewing this thread

Back
Top Bottom