hhhh

Sub ImporterIdFluxDepuisDernierDossier()


    Dim basePath As String

    Dim lastFolder As String

    Dim fso As Object, folder As Object, subFolder As Object

    Dim newestDate As Date

    Dim xmlFile As String

    Dim xmlDoc As Object

    Dim idFluxValue As String

    

    ' Dossier de base

    basePath = "C:\Users\A447HW\AppData\Local\SuiviProd\AXA\"

    

    ' Création FileSystemObject

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set folder = fso.GetFolder(basePath)

    

    newestDate = 0

    lastFolder = ""

    

    ' Trouver le dernier sous-dossier créé

    For Each subFolder In folder.SubFolders

        If subFolder.DateCreated > newestDate Then

            newestDate = subFolder.DateCreated

            lastFolder = subFolder.Path

        End If

    Next subFolder

    

    If lastFolder = "" Then

        MsgBox "Aucun sous-dossier trouvé dans : " & basePath, vbExclamation

        Exit Sub

    End If

    

    ' Chercher le fichier XML dans le dernier dossier

    xmlFile = Dir(lastFolder & "\AXA_FluxCourriers_RTI_*.xml")

    

    If xmlFile = "" Then

        MsgBox "Aucun fichier 'AXA_FluxCourriers_RTI_*.xml' trouvé dans : " & lastFolder, vbExclamation

        Exit Sub

    End If

    

    ' Charger XML

    Set xmlDoc = CreateObject("MSXML2.DOMDocument")

    xmlDoc.async = False

    xmlDoc.Load lastFolder & "\" & xmlFile

    

    ' Extraire la valeur <idFlux>

    If Not xmlDoc Is Nothing Then

        On Error Resume Next

        idFluxValue = xmlDoc.SelectSingleNode("//idFlux").Text

        On Error GoTo 0

    End If

    

    If idFluxValue = "" Then

        MsgBox "Balise <idFlux> introuvable dans le fichier : " & xmlFile, vbExclamation

        Exit Sub

    End If

    

    ' Mettre la valeur dans C5 de OLD Maquette

    Sheets("OLD Maquette").Range("C5").Value = idFluxValue

    

    MsgBox "Import terminé : " & idFluxValue, vbInformation


End Sub


Popular posts from this blog

Privacy Policy Speedy Runner

PRIVACY POLICY - Best 40 Hair Salon Girl Games