FileSystemObject Problem - "fso is nothing"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    FileSystemObject Problem - "fso is nothing"

    Hey guys,

    I was asked to help solve an issue another developer was having and I personally don't know much about it so I am turning to you guys for a little help/guidance.

    My co-worker has created an ASP page that is trying to pull the latest report from the network. And the ASP is failing when it tries to create the FSO to scan the files. A virtual directory has not been created yet so he is pointing directly to the network path.

    The page is using the FSO and excel, and when i click on one of the Excel report links i get "fso is nothing"


    Here is the code:

    Code:
     Function GetLatestReport(path, rptName)
            Dim fso
            Dim rptFolder
            Dim rptDate
            Dim fiTemp
            Dim fi
            Dim report
            Dim x
            Dim msg 
           
        On error Resume Next
            
            msg = ""
            
            Set fso = CreateObject("Scripting.FileSystemObject")
    
            Window.status = "Retrieving " & rptName
                
            rptDate = CDate("1/1/1900")
                   
            Set rptFolder = fso.GetFolder(path)
            
            If rptFolder Is Nothing Then
                msg = msg & "Could not find path to " & rptName & chr(13)
            Else
                For Each fi in rptFolder.Files
    				msgbox fi.Name
                    If err.number <> 0 Then
                        msg = msg & err.Description & chr(13)
                        err.Clear 
                    Else
                        If InStr(1, Ucase(fi.Name), UCase(rptName)) > 0 Then
                            If fi.DateCreated > rptDate Then
                                Set fiTemp = fi
                                rptDate = fiTemp.DateCreated
                            End If
                        ElseIf fi.Name > rptName Then
                            Exit For               
                        End If
                    End If
                Next
    
                report = fiTemp.Path
            End If
                                        
            If msg <> "" Then
                Msgbox "The following errors occurred during the page load:" & chr(13) & chr(13) &   msg
            End If
            
            Set fso = Nothing
            
            GetLatestReport = report
        End Function
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Stang02GT,

    Which line does it fail on if you comment out the "On error Resume Next" line and then run it again?

    Also, the FSO can have problems using network paths (e.g. <server><share> <filename>). Is the folder you're trying to reference remote or local?

    Dr B

    Comment

    • Stang02GT
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      I think the issue lies with your second statement. The folder is remote, its on a server.

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Can you try testing it on a local path to see if it works? Let me know how it goes.

        Dr B

        Comment

        • Stang02GT
          Recognized Expert Top Contributor
          • Jun 2007
          • 1206

          #5
          Originally posted by DrBunchman
          Can you try testing it on a local path to see if it works? Let me know how it goes.

          Dr B
          I will do that. Thank you very much for you help!

          Comment

          Working...