Results 1 to 20 of 119

Thread: Process All CSV Files In SubFolders

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,954
    Location
    We have already taken care of the space character issue in previous code. SNB explained it again in his code. For Sam's code you need to add those quote characters to take care of the space characters.
    Of course when you do this, checks for folder or filename existence use Dir() as I demonstrated, will fail. I normally just define a string as Sam did and then add the quote characters by concatenating them via q where q="""".

       Const FolderPath As String = """C:\Users\dbrandejs\david\skola\IES\Diplomka\adjusted data\allstocks_20130102\""" 'include ending \
    This is really something that you should be addressing. Use the debugging methods that I detailed in some past post here. We can only do so much for you.

    We did some error checks but there are others that can be done.
    Sub ken()   
      Dim FolderPath As String, q As String, fn As String, Msg As String
       
       On Error GoTo ErrMsg
       
       q = """"
       FolderPath = "C:\Users\dbrandejs\david\skola\IES\Diplomka\adjusted data\allstocks_20130102\" 'include ending \
       
       fn = q & FolderPath & q
       
       MsgBox FolderPath & vbLf & "Exists? " & (Dir(FolderPath, vbDirectory) <> "")
       'Next line will error:
       MsgBox fn & vbLf & "Exists? " & (Dir(fn, vbDirectory) <> "")
       
        'Exit Sub
    ErrMsg:
        If Err.Number <> 0 Then
            Msg = "Error # " & Str(Err.Number) & " was generated by " _
                    & Err.Source & Chr(13) & Err.Description
            MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
            Exit Sub
        End If
    End Sub
    Last edited by Kenneth Hobs; 06-02-2015 at 12:34 PM.

Posting Permissions

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