Bonjour

A la suite d'un traitement lambda sur un fichier Excel, je souhaites l'archiver dans un répertoire "Archivage" et lui changer de nom. Le renomage dépend de la version Excel .xls ou .xlsx
exemple : fichier.xlsx -->fichier_date.xlsx et fichier.xls -->fichier_date.xls.

voilà mon bout de code qui plante :
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
Public Sub Main()
        ' Add your code here
        Dim sSrcFile As String
        Dim sSrcFolder As String
        Dim sDesFile As String
        Dim sDesFolder As String
 
        sSrcFile = Dts.Variables("SrcFile").Value.ToString
        sSrcFolder = Dts.Variables("SrcFolder").Value.ToString
        sDesFolder = Dts.Variables("DesFolder").Value.ToString
 
       If (sSrcFile.Substring(0, sSrcFile.Length - 1)) = "x" Then
        sDesFile = sDesFolder & sSrcFile.Substring(0, sSrcFile.Length - 5) & "_" & Today.ToString("dd-MM-yyyy") & sSrcFile.Substring(sSrcFile.Length - 5, 5)
       Else
        'sDesFile = sDesFolder & sSrcFile.Substring(0, sSrcFile.Length - 4) & "_" & Today.ToString("dd-MM-yyyy") & sSrcFile.Substring(sSrcFile.Length - 4, 4)
       End If
'....etc....
End Sub
Merci de votre aide.