j'ai utilis=E9 un exemple pour faire du publipostage excel-excel grace =E0
cette macro
fichier ex ici http://cjoint.com/?kwxKH3aO7N
Sub imprime()
For i =3D 2 To Sheets("Base").Rows.Count
Range("compteur") =3D i
If Sheets("Base").Cells(i, 1).Value =3D Empty Then
Exit Sub
End If
Sheets("Mod=E8le").PrintOut Copies:=3D1, Collate:=3DTrue
Next
End Sub
or en imprimant vers pdf creator pour pouvoir obtenir un fichier pdf,
il m'imprime le nom du classeur actif
ne serais t il pas possible qu'il l'enregiste sous le format nom et
prenom.pdf
Sub printtest_1() 'La feuille active. a = ActiveSheet.Name Call printsheetinpdf(Sheets(a)) End Sub
Sub printtest_2() 'Quelques feuilles du classeur, à adapter. a = ActiveSheet.Name b = "Annexe" c = Sheets(3) Call printsheetinpdf(Sheets(Array(a, b, c))) End Sub
Sub printtest_3() 'Le classeur entier. Call printsheetinpdf(ActiveWorkbook) End Sub
Sub printsheetinpdf(shsheet As Object) Dim pdfjob As Object Dim spdfname As String Dim spdfpath As String spdfname = "Fiche navette_" & Range("h8") & "_" & Format(Date, "dd-mm-yyyy") & ".pdf" 'Nom du fichier, à adapter spdfpath = "c:zz" 'Documents and Settings" & UCase(Environ("username")) & "Mes documents" 'Nom du chemin, à adapter Call killtask("PDFCreator.exe") Set pdfjob = CreateObject("PDFCreator.clsPDFCreator") With pdfjob If .cstart("/NoProcessingAtStartup") = False Then MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator" Exit Sub End If .cOption("UseAutosave") = 1 .cOption("UseAutisaveDirectory") = 1 .cOption("AutosaveDirectory") = spdfpath .cOption("AutosaveFilename") = spdfname .cOption("AutosaveFormat") = 0 .cClearCache End With shsheet.PrintOut copies:=1, ActivePrinter:="PDFCreator" Do Until pdfjob.cCountOfPrintjobs = 1 DoEvents Loop pdfjob.cPrinterStop = False Do Until pdfjob.cCountOfPrintjobs = 0 DoEvents Loop With pdfjob .cDefaultprinter = defaultprinter .cClearCache Application.Wait (Now + TimeValue("0:00:3")) .cClose End With Set pdfjob = Nothing End Sub
Sub killtask(sappname As String) Dim oProclist As Object Dim oWMI As Object Dim oProc As Object Set oWMI = GetObject("winmgmts:") If IsNull(oWMI) = False Then Set oProclist = oWMI.InstancesOf("win32_process") For Each oProc In oProclist If UCase(oProc.Name) = UCase(sappname) Then oProc.Terminate (0) End If Next oProc Else MsgBox "Killing """ & sappname & """ - Can't create WMI Object.", vbOKOnly, vbCritical, "CloseAPP_B" End If Set oProclist = Nothing Set oWMI = Nothing End Sub
isabelle
magic-dd a écrit :
bonjour
j'ai utilisé un exemple pour faire du publipostage excel-excel grace à cette macro
fichier ex ici http://cjoint.com/?kwxKH3aO7N
Sub imprime() For i = 2 To Sheets("Base").Rows.Count Range("compteur") = i If Sheets("Base").Cells(i, 1).Value = Empty Then Exit Sub End If Sheets("Modèle").PrintOut Copies:=1, Collate:=True Next End Sub
or en imprimant vers pdf creator pour pouvoir obtenir un fichier pdf, il m'imprime le nom du classeur actif
ne serais t il pas possible qu'il l'enregiste sous le format nom et prenom.pdf
Sub printtest_1()
'La feuille active.
a = ActiveSheet.Name
Call printsheetinpdf(Sheets(a))
End Sub
Sub printtest_2()
'Quelques feuilles du classeur, à adapter.
a = ActiveSheet.Name
b = "Annexe"
c = Sheets(3)
Call printsheetinpdf(Sheets(Array(a, b, c)))
End Sub
Sub printtest_3()
'Le classeur entier.
Call printsheetinpdf(ActiveWorkbook)
End Sub
Sub printsheetinpdf(shsheet As Object)
Dim pdfjob As Object
Dim spdfname As String
Dim spdfpath As String
spdfname = "Fiche navette_" & Range("h8") & "_" & Format(Date,
"dd-mm-yyyy") & ".pdf" 'Nom du fichier, à adapter
spdfpath = "c:zz" 'Documents and Settings" &
UCase(Environ("username")) & "Mes documents" 'Nom du chemin, à adapter
Call killtask("PDFCreator.exe")
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly,
"PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = spdfpath
.cOption("AutosaveFilename") = spdfname
.cOption("AutosaveFormat") = 0
.cClearCache
End With
shsheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = defaultprinter
.cClearCache
Application.Wait (Now + TimeValue("0:00:3"))
.cClose
End With
Set pdfjob = Nothing
End Sub
Sub killtask(sappname As String)
Dim oProclist As Object
Dim oWMI As Object
Dim oProc As Object
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
Set oProclist = oWMI.InstancesOf("win32_process")
For Each oProc In oProclist
If UCase(oProc.Name) = UCase(sappname) Then
oProc.Terminate (0)
End If
Next oProc
Else
MsgBox "Killing """ & sappname & """ - Can't create WMI Object.",
vbOKOnly, vbCritical, "CloseAPP_B"
End If
Set oProclist = Nothing
Set oWMI = Nothing
End Sub
isabelle
magic-dd a écrit :
bonjour
j'ai utilisé un exemple pour faire du publipostage excel-excel grace à
cette macro
fichier ex ici http://cjoint.com/?kwxKH3aO7N
Sub imprime()
For i = 2 To Sheets("Base").Rows.Count
Range("compteur") = i
If Sheets("Base").Cells(i, 1).Value = Empty Then
Exit Sub
End If
Sheets("Modèle").PrintOut Copies:=1, Collate:=True
Next
End Sub
or en imprimant vers pdf creator pour pouvoir obtenir un fichier pdf,
il m'imprime le nom du classeur actif
ne serais t il pas possible qu'il l'enregiste sous le format nom et
prenom.pdf
Sub printtest_1() 'La feuille active. a = ActiveSheet.Name Call printsheetinpdf(Sheets(a)) End Sub
Sub printtest_2() 'Quelques feuilles du classeur, à adapter. a = ActiveSheet.Name b = "Annexe" c = Sheets(3) Call printsheetinpdf(Sheets(Array(a, b, c))) End Sub
Sub printtest_3() 'Le classeur entier. Call printsheetinpdf(ActiveWorkbook) End Sub
Sub printsheetinpdf(shsheet As Object) Dim pdfjob As Object Dim spdfname As String Dim spdfpath As String spdfname = "Fiche navette_" & Range("h8") & "_" & Format(Date, "dd-mm-yyyy") & ".pdf" 'Nom du fichier, à adapter spdfpath = "c:zz" 'Documents and Settings" & UCase(Environ("username")) & "Mes documents" 'Nom du chemin, à adapter Call killtask("PDFCreator.exe") Set pdfjob = CreateObject("PDFCreator.clsPDFCreator") With pdfjob If .cstart("/NoProcessingAtStartup") = False Then MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator" Exit Sub End If .cOption("UseAutosave") = 1 .cOption("UseAutisaveDirectory") = 1 .cOption("AutosaveDirectory") = spdfpath .cOption("AutosaveFilename") = spdfname .cOption("AutosaveFormat") = 0 .cClearCache End With shsheet.PrintOut copies:=1, ActivePrinter:="PDFCreator" Do Until pdfjob.cCountOfPrintjobs = 1 DoEvents Loop pdfjob.cPrinterStop = False Do Until pdfjob.cCountOfPrintjobs = 0 DoEvents Loop With pdfjob .cDefaultprinter = defaultprinter .cClearCache Application.Wait (Now + TimeValue("0:00:3")) .cClose End With Set pdfjob = Nothing End Sub
Sub killtask(sappname As String) Dim oProclist As Object Dim oWMI As Object Dim oProc As Object Set oWMI = GetObject("winmgmts:") If IsNull(oWMI) = False Then Set oProclist = oWMI.InstancesOf("win32_process") For Each oProc In oProclist If UCase(oProc.Name) = UCase(sappname) Then oProc.Terminate (0) End If Next oProc Else MsgBox "Killing """ & sappname & """ - Can't create WMI Object.", vbOKOnly, vbCritical, "CloseAPP_B" End If Set oProclist = Nothing Set oWMI = Nothing End Sub
isabelle
magic-dd a écrit :
bonjour
j'ai utilisé un exemple pour faire du publipostage excel-excel grace à cette macro
fichier ex ici http://cjoint.com/?kwxKH3aO7N
Sub imprime() For i = 2 To Sheets("Base").Rows.Count Range("compteur") = i If Sheets("Base").Cells(i, 1).Value = Empty Then Exit Sub End If Sheets("Modèle").PrintOut Copies:=1, Collate:=True Next End Sub
or en imprimant vers pdf creator pour pouvoir obtenir un fichier pdf, il m'imprime le nom du classeur actif
ne serais t il pas possible qu'il l'enregiste sous le format nom et prenom.pdf
merci de vos conseil
magic-dd
décidément isabelle, tu viens souvent à ma rescousse et je t'en suis fort reconnaissant
je vais regarder cet exemple et essayer de l'adapter à mon cas.
à bientot si je bloque
décidément isabelle, tu viens souvent à ma rescousse et je t'en suis
fort reconnaissant
je vais regarder cet exemple et essayer de l'adapter à mon cas.