Bonjour le forum,
J'ai un dossier contenant pas loin de 800 fichiers (.xls, .xlsx, .xlsm) que je dois convertir en pdf.
Mon problème est que, même si ces fichiers ne sont pas très lourds, ils sont remplis d'images et de formes, et cela ralentit énormément leur ouverture.
J'ai fait un test avec le code suivant et un dossier qui ne comprenait qu'un fichier Excel.
Résultat, deux minutes pour la conversion d'un seul fichier. Si je calcule bien, ça veut dire que la conversion des mes 800 fichiers prendrait plus de 26h...
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 Sub BoucleEtConversionPDF() Dim strChemin As String, strFichier As String, strTitre As String, strCheminPDF t0 = Timer strChemin = "" strFichier = "" strTitre = "" With Application .ScreenUpdating = False .DisplayAlerts = False .EnableEvents = False End With strChemin = "blablabla" strCheminPDF = "blablabla" strFichier = Dir(strChemin & "*.*") Do While Len(strFichier) > 0 Workbooks.Open Filename:=strChemin & strFichier, UpdateLinks:=False strTitre = Left(strFichier, InStr(1, strFichier, ".", vbTextCompare) - 1) Application.Calculation = xlCalculationManual Workbooks(strFichier).ExportAsFixedFormat xlTypePDF, strCheminPDF & strTitre Application.Calculation = xlCalculationAutomatic Workbooks(strFichier).Close False strFichier = Dir() Loop With Application .ScreenUpdating = True .DisplayAlerts = True .EnableEvents = True End With T1 = Timer Debug.Print "Exécution Exportation : " & Format(T1 - t0, "0.000") & " s" End Sub
Alors je me demandais s'il y avait un moyen de convertir sans passer par la case ouverture...
Partager