Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Pb creation fichier par pdfcreator depuis macro vba

1 réponse
Avatar
muadhib34
Bonjour à tous
Et d’abord, merci pour vos contributions, j’ai jusqu'à maintenant puisé sans vergogne dans vos codes avec bonheur
Mais là, ca coince, et je n’ai pas trouver de réponse à mon pb
Donc
A partir d’un fichier excel de x feuilles, après creation d un userform ou je demande quelles feuilles doivent etre imprimées je genere une impression soit sous excel soit sous pdfcreator
Pas de souci dans tout cela
L’impression excel a pas de souci et je créé correctement mon fichier pdf.
Mais impossible de l’ouvrir avec adobe, fichier endommagé ou transmis par mail et mal décodé.
La génération manuelle de ce fichier fonctionne, j’ai tenté avec l’enregistreur sans plus de succés ( dans ce cas precis il est tres peu causant)

Fonctionnement sous windows server 2003
Excel 2000, adobe 7, pdf creator 0.9.3

Mon code

' coche les feuilles à imprimer
For xx = 1 To wa
If imprime_projet.Controls("flagimp" & xx).Value = True Then
Sheets(imprime_projet.Controls("flagimp" & xx).Caption).Select True
xy = xy + 1
End If
Next xx
If xy = 0 Then GoTo fin_impression 'fin si aucune selectionnée
'annule la feuille en cours de travail si elle n a pas été selectionnée
For xx = 1 To wa
If imprime_projet.Controls("flagimp" & xx).Value = True Then
Else
Sheets(imprime_projet.Controls("flagimp" & xx).Caption).Select False
End If
Next xx
'impression sous excel
If imprime_projet.ok_excel.Value = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
'impression sous pdf
If imprime_projet.ok_pdf.Value = True Then
imprimante = Application.ActivePrinter
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox " PDFCreator.Indisponible", vbCritical + vbOKOnly, "Erreur d’impression"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ThisWorkbook.Path & "\"
.cOption("AutosaveFilename") = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & ".pdf"
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Enregistrement de la feuille au format pdf par pdfCretor
nom = ThisWorkbook.Path & "\" & Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & ".pdf"
Application.ActiveWindow.SelectedSheets.PrintOut copies:=1, ActivePrinter:="PDFCreator sur Ne00:", Collate:=True, PrintToFile:=True, PrToFileName:=nom
'''
Application.ActivePrinter = imprimante
End If
imprime_projet.flag_print = 0
End If
fin_impression:
xy = 0: wa = 0
Unload imprime_projet
End Sub

Qq'un voit il a sa ne va pas?

Merci d'avance

1 réponse

Avatar
muadhib34
muadhib34 a écrit le 18/11/2008 à 11h00 :
Bonjour à tous
Et d’abord, merci pour vos contributions, j’ai jusqu'à
maintenant puisé sans vergogne dans vos codes avec bonheur
Mais là, ca coince, et je n’ai pas trouver de réponse
à mon pb
Donc
A partir d’un fichier excel de x feuilles, après creation d un
userform ou je demande quelles feuilles doivent etre imprimées je genere
une impression soit sous excel soit sous pdfcreator
Pas de souci dans tout cela
L’impression excel a pas de souci et je créé correctement
mon fichier pdf.
Mais impossible de l’ouvrir avec adobe, fichier endommagé ou
transmis par mail et mal décodé.
La génération manuelle de ce fichier fonctionne, j’ai
tenté avec l’enregistreur sans plus de succés ( dans ce cas
precis il est tres peu causant)

Fonctionnement sous windows server 2003
Excel 2000, adobe 7, pdf creator 0.9.3

Mon code

' coche les feuilles à imprimer
For xx = 1 To wa
If imprime_projet.Controls("flagimp" & xx).Value = True
Then
Sheets(imprime_projet.Controls("flagimp" &
xx).Caption).Select True
xy = xy + 1
End If
Next xx
If xy = 0 Then GoTo fin_impression 'fin si aucune selectionnée
'annule la feuille en cours de travail si elle n a pas été
selectionnée
For xx = 1 To wa
If imprime_projet.Controls("flagimp" & xx).Value = True
Then
Else
Sheets(imprime_projet.Controls("flagimp" &
xx).Caption).Select False
End If
Next xx
'impression sous excel
If imprime_projet.ok_excel.Value = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
'impression sous pdf
If imprime_projet.ok_pdf.Value = True Then
imprimante = Application.ActivePrinter
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox " PDFCreator.Indisponible", vbCritical + vbOKOnly,
"Erreur d’impression"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ThisWorkbook.Path &
""
.cOption("AutosaveFilename") = Left(ThisWorkbook.Name,
Len(ThisWorkbook.Name) - 4) & ".pdf"
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Enregistrement de la feuille au format pdf par pdfCretor
nom = ThisWorkbook.Path & "" &
Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & ".pdf"
Application.ActiveWindow.SelectedSheets.PrintOut copies:=1,
ActivePrinter:="PDFCreator sur Ne00:", Collate:=True,
PrintToFile:=True, PrToFileName:=nom
'''
Application.ActivePrinter = imprimante
End If
imprime_projet.flag_print = 0
End If
fin_impression:
xy = 0: wa = 0
Unload imprime_projet
End Sub

Qq'un voit il a sa ne va pas?

Merci d'avance


Désolé,
Suite mauvaise manip sur réactualisation de page j'ai posté 2 fois ce fil
Ne pas en tenir coompte il fait double emploi avec celui de 8h45 !!!!