Bonjour à tous,
J'aurai besoin de conseils, sur un code créer qui récupère les titres à partir de flux RSS afin de créer une newsletter trimestrielle. Mon problème, quand je lance la macro, oK, mais cela me récupére les différents articles des différents flux, mais sur 2 mois et non sur 90 jours. Quelqu'un(e) aurait une idée ? mon code pour la partie date ci-dessous, et merci pour votre aide :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Function ParseRSSDateV2(pubDateStr As String) As Date
    Dim moisFrancais As Variant, moisAnglais As Variant
    Dim i As Integer, nbJours As Integer
    Dim temp As String
 
    On Error Resume Next
    pubDateStr = Trim(LCase(pubDateStr))
 
    ' === 1. Format relatif "il y a X jour(s)" ===
    If InStr(pubDateStr, "il y a") > 0 Then
        temp = Replace(pubDateStr, "il y a", "")
        temp = Replace(temp, "jours", "")
        temp = Replace(temp, "jour", "")
        temp = Trim(temp)
        nbJours = Val(temp)
        If nbJours > 0 Then
            ParseRSSDateV2 = Date - nbJours
            Exit Function
        End If
    End If
 
    ' === 2. Format JJ/MM/AAAA ou reconnu directement ===
    If IsDate(pubDateStr) Then
        ParseRSSDateV2 = CDate(pubDateStr)
        Exit Function
    End If
 
    ' === 3. Format anglais "September 17, 2025" ou "October 2025" ===
    moisAnglais = Array("january", "february", "march", "april", "may", "june", _
                        "july", "august", "september", "october", "november", "december")
    For i = 0 To 11
        If InStr(pubDateStr, moisAnglais(i)) > 0 Then
            ' Format complet "September 17, 2025"
            If InStr(pubDateStr, ",") > 0 Or InStr(pubDateStr, " ") > 0 Then
                temp = Replace(pubDateStr, ",", "")
                ParseRSSDateV2 = CDate(temp)
                If Err.Number = 0 Then Exit Function
            End If
            ' Format partiel "October 2025"
            If IsNumeric(Right(pubDateStr, 4)) Then
                ParseRSSDateV2 = DateSerial(Right(pubDateStr, 4), i + 1, 1)
                Exit Function
            End If
        End If
    Next i
 
    ' === 4. Format français "17 septembre 2025" ou "octobre 2025" ===
    moisFrancais = Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", _
                         "août", "septembre", "octobre", "novembre", "décembre")
    For i = 0 To 11
        If InStr(pubDateStr, moisFrancais(i)) > 0 Then
            temp = Replace(pubDateStr, moisFrancais(i), CStr(i + 1))
            temp = Replace(temp, ",", "")
            temp = Trim(temp)
            ' Format complet "17 septembre 2025"
            If IsNumeric(Left(temp, 2)) And IsNumeric(Right(temp, 4)) Then
                ParseRSSDateV2 = CDate(Left(temp, 2) & "/" & (i + 1) & "/" & Right(temp, 4))
                Exit Function
            End If
            ' Format partiel "octobre 2025"
            If IsNumeric(Right(temp, 4)) Then
                ParseRSSDateV2 = DateSerial(Right(temp, 4), i + 1, 1)
                Exit Function
            End If
        End If
    Next i
 
Debug.Print "Brut : " & pubDateStr & " ? Interprété : " & dateArticle
    ' === Si tout échoue ===
    ParseRSSDateV2 = 0
End Function