Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shell command (2002)

    I'm trying to check for the existence of a file and then delete it if found. I'm having problems passing a string to the shell command. I pasted the code below, if anyone can be of help. Every time the code runs it give me an error 53 file not found, I've looked at this code so many times I'm missing something obvious I think.


    ' Example: ParcelPath = mcguffey 2674 ParcelData.csv


    strFileName = Dir("C:PROPER~1IMAGES" & rsprprts.Fields("ParcelPath"))

    If strFileName <> "" Then

    strIimCmd = rsprprts.Fields("ParcelPath")

    intDelCmd1 = InStr(1, rsprprts.Fields("ParcelPath"), " ")
    intDelCmd2 = InStr(intDelCmd1 + 1, rsprprts.Fields("ParcelPath"), " ")

    strDelCmd = Mid(rsprprts.Fields("ParcelPath"), 1, intDelCmd1 - 1)
    strDelCmd1 = Mid(rsprprts.Fields("ParcelPath"), intDelCmd1 + 1, (intDelCmd2 - 1) - intDelCmd1)
    strDelCmd2 = Mid(rsprprts.Fields("ParcelPath"), intDelCmd2 + 1)

    strShlCmd = "del C:PropertyImagesImages" & strDelCmd
    strShlCmd = strShlCmd + Chr(34) & " " & Chr(34) & strDelCmd1
    strShlCmd = strShlCmd + Chr(34) & " " & Chr(34) & strDelCmd2

    End If

    Shell strShlCmd, vbMaximizedFocus

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Shell command (2002)

    What precisely are you trying to do that requires the Shell command? A DIR() function with the appropriate path and filename can tell you whether the file exists, and a Kill statement will delete it.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shell command (2002)

    I was trying to make this more difficult than it needed to be. I was trying to issue a delete command in a shell to remove the file if it existed. I'm in the process of learning Access/VBA, either I overlooked the kill statement or I didn't use good search criteria in help, because it just made things much simpler for me. Thanks for the help, you just made my day. <img src=/S/cloud9.gif border=0 alt=cloud9 width=25 height=23>

Posting Permissions

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