I am prompting my user for a string that will be used as the destination name in a file copy, as indicated in the code below. This works fine if the user does not include any spaces in the new file name. If they do, they get the DOS error “The syntax of the command is incorrect.”. DOS requires surrounding quotes if there are spaces, ei: copy test.mdb “test number 2.mdb”
I have been trying to edit a.WriteLine (“copy ” & strDBPath & ” ” & CurrentDBDir & NewDBName & “.MDB”) so it will enclose the CurrentDBDir & NewDBName & “.MDB” in quotes so DOS will accept it. I thought that I had handled a situation like this sucessfully in the past, but haven’t been able to conquer it this time.
Thanks,
Randy
””””””””””””””””””””””””””””””””””””””””’
strMsg = "Enter IMP Database Name, without .MDB extension (EI: MAY01IMP)" NewDBName = InputBox(Prompt:=strMsg, Title:="Build IMP Database", XPos:=2000, YPos:=2000) If NewDBName = "" Then Exit Function End If DoCmd.Hourglass True Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile(CurrentDBDir & "CopyDupsMDB.bat", True) a.WriteLine ("copy " & strDBPath & " " & CurrentDBDir & NewDBName & ".MDB") a.WriteLine BatchCommand a.Close Call Shell(CurrentDBDir & "CopyDupsMDB.bat", 1) DoCmd.Hourglass False
””””””””””””””””””””””””””””””””””””””””’