Bonjour,
J'aurai besoin de votre aide pour la macro ci-dessous sensée me donner une impression PDF + enregistrement dans un dossier avec un nom de fichier composé des données bookmarks de mon document, malheureusement celle-ci me renvoie :
"Erreur d'execution '429' : Un composant ActiveX ne peut pas créer d'objet"
Pourtant dans les références de VB, j'ai bien cocher :
- "PDF Creator - Your Open Source PDF Creator "
Voyez-vous une solution ?
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 Sub ToPdf() Set pdfjob = CreateObject("PDFCreator.clsPDFCreator") If ActiveDocument.Bookmarks.Exists("Titre") = True Then Else: MsgBox "Erreur, le signet titres n'existe pas", vbOKOnly, "Erreur" End If If ActiveDocument.Bookmarks.Exists("Code") = True Then Else: MsgBox "Erreur, le signet Code n'existe pas", vbOKOnly, "Erreur" End If 'Avant : NomWord = ActiveDocument.Name NomWord = ActiveDocument.Bookmarks("Titre").Range.Text & "-" & ActiveDocument.Bookmarks("Code").Range.Text NomPdf = Left(NomWord, Len(NomWord) - 4) & ".pdf" With pdfjob If .cstart("/NoProcessingAtStartup") = False Then MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator" Exit Sub End If .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveDirectory") = ActiveDocument.Path .cOption("AutosaveFilename") = NomPdf .cOption("AutosaveFormat") = 0 .cClearCache End With Application.ActivePrinter = "PDFCreator" Application.ActiveDocument.PrintOut copies:=1 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 Set pdfjob = Nothing End Sub
Merci par avance pour le temps consacré !
Jane
Partager