Bonjour à tous,
actuellement je travaille sur une macro qui me permettrait de découper un fichier pdf (500 pages) en autant de fichier qu'il a de page, en renommant chaque fichier en fonction d'une valeur situé dans un tableau Excel.
j'ai alors ce code qui ne marche pas :
Quelqu'un pourrait il m'apporter son aide pour corriger et comprendre les erreurs commises ?
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 Dim ligne As Long ligne = 2 Dim i As Long 'fichier à ouvrir fichier= "D:\Documents and Settings\Bureau\test catalogue\test.pdf" 'on précise où l'on va stocker le fichier créer chemin = "D:\Documents and Settings\Bureau\test catalogue\" ' a partir du fichier excel , on prend la valeur se trouvant sur la premiere colonne pour nommer le fichier ainsi creer While ActiveSheet.Cells(ligne, 1).Value <> "" 'nom du fichier NomPDF = left("Idée -" & ActiveSheet.Cells(ligne, 3).Value, Len("Idée -" & ActiveSheet.Cells(ligne, 4).Value) - 4) & ".pdf" Set pdfjob = CreateObject("PDFCreator.clsPDFCreator") With pdfjob If .cStart("/NoProcessingAtStartup") = False Then MsgBox "Initialisation de PDFCreator impossible", vbCritical + vbOKOnly, "PrtPDFCreator" Exit Sub End If .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveDirectory") = chemin .cOption("AutosaveFilename") = NomPDF .cOption("AutosaveFormat") = 0 '0 pour pdf .cClearCache End With i = ligne 1 ActivePrinter = "PDFCreator sur Ne00:" Application.PrintOut Filename:="", Range:=fichier, Item:= _ PrintDocumentContent, From:=i, To:=i, Copies:=1 Application.PrintOut Do Until pdfjob.cCountOfPrintjobs = 1 DoEvents Loop pdfjob.cPrinterStop = False Do Until pdfjob.cCountOfPrintjobs = 0 DoEvents Loop With pdfjob .cDefaultPrinter = DefaultPrinter .cClearCache .cClose End With Wend
Merci
JB
Partager