0

I have some troubles while I want to debug this. "The reference of the object is not defined as an object instance"

I don't know where I missed something .. Thanks a lot.

Module Conversion
    Public Sub ConversionFromCurrentToOld()
        Dim FSO As Scripting.FileSystemObject
        Dim oFolder As Scripting.Folder
        Dim oFile As Scripting.File
        Dim compteur_fichier = 0

        Try

            oFolder = FSO.GetFolder(Dossier_source)
            For Each oFile In oFolder.Files
                If UCase(Right(oFile.Name, 3)) = "ARD" Then
                    With Fichier_ACAM
                        .OpenDrawing(oFile.Path)
                        .ActiveDrawing.SaveAsEx(Dossier_destination & "\" & oFile.Name, 18)
                    End With
                    compteur_fichier += 1
                End If
                MsgBox("Test : " & compteur_fichier)
            Next
        Catch ex As Exception
            MessageBox.Show(String.Format("Erreur: {0}", ex.Message))
        End Try
    End Sub
End Module
  • 2
    You never initialized `FSO`. It should be `Dim FSO As New Scripting.FileSystemObject`. That said, you should really get familiar with the .NET way of doing things. Start with the [`System.IO` namespace](https://learn.microsoft.com/en-us/dotnet/api/system.io?view=net-5.0). – 41686d6564 stands w. Palestine Aug 31 '21 at 12:52
  • 1
    @Steve It's definitely VB.NET. The `try`/`catch`, `MesageBox.Show` and `String.Format` gave it away. – Alejandro Aug 31 '21 at 12:54

0 Answers0