Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    This command works at the command line and removes Streets and any sub direcrories
    rd "F:PropertiesStreets" /s /q

    Iím trying to run this command in VBA and getting rte 53 file not found on the following:

    Call Shell(stAppName, 1)

    Contents of stAppName is "rd F:PropertiesStreets /s /q"

    What is the proper syntax?

    Thanks, John

    <pre>Sub Remove_Property_Folders()

    ChDrive "F" ' Make "F" the current drive.
    ChDir "F:Properties" ' Change current directory or folder

    Dim stAppName As String

    stAppName = "rd F:PropertiesStreets /s /q" 'rd "F:PropertiesStreets" /s /q

    Call Shell(stAppName, 1)

    MkDir "Streets" ' Make current directory or folder

    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    rd is not an executable. Use this:
    <code>
    stAppName = "cmd /c rd F:PropertiesStreets /s /q"
    </code>
    cmd is the command processor cmd.exe.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Fantastic!

    The only way the following works is with msgbox bewteen calls. I think I have a timing issue.

    The folder is removed but not created without the msgbox

    Is there a way to do this without msgbox?

    Thanks, John


    <pre>Sub Remove_Make_Properties_Streets_Folders()

    Call Remove_Properties_Streets_Folders

    MsgBox "PropertiesStreets Removed"

    Call Make_Properties_Streest_Folder

    End Sub
    </pre>


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You could try inserting a

    DoEvents

    or two.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    10 DoEvents didn't get it, the following seems to work:

    Thanks, John

    <pre> Dim I, OpenForms
    For I = 1 To 150000 ' Start loop.
    If I Mod 1000 = 0 Then ' If loop has repeated 1000 times.
    OpenForms = DoEvents ' Yield to operating system.
    End If
    Next I ' Increment loop counter.
    </pre>


  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    That is equivalent to the simpler

    Dim I As Integer
    For I = 1 To 150
    DoEvents
    Next I

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •