Terminate Shell

Steve R.

Retired
Local time
, 22:30
Joined
Jul 5, 2006
Messages
5,150
To create a listing of mp3 songs as a text file, I am using the shell command. In theory, the "/c" switch is supposed to terminate the shell when the command "dir" completes. Also Access help has the following notation "By default, the Shell function runs other programs asynchronously. This means that a program started with Shell might not finish executing before the statements following the Shell function are executed."

Apparently, the Shell command is not terminating before getting to the DoCmd statement and I get an error message that the "Music.txt" file is not accessible because it is locked. Is there a way to force the Shell to complete before getting to the DoCmd statement?


Code:
Shell "cmd.exe /c dir *.mp3 /S /B > Music.txt", vbHide
Rem shell needs to close before continuing with DoCmd
DoCmd.TransferText acImportDelim, "Music Import Specification", strMP3TableName, strMP3SourceFileName

PS: This may be the solution, to late to pursue now. ACC: Using the Shell() Function to Run MS-DOS Commands
 
Last edited:
It worked!
Code:
ShellWait "cmd /c dir C:\*.doc /s /b > Ztest.txt", 1
    DoCmd.TransferText acImportDelim, , "FileNames", "Ztest.txt"
Thanks.
 

Users who are viewing this thread

Back
Top Bottom