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
|
Sub CréerPDFetDocxIndivi()
nom = ActiveDocument.MailMerge.DataSource.DataFields(3).Value
With ActiveDocument.MailMerge
.DataSource.ActiveRecord = wdLastRecord
LastRecord = .DataSource.ActiveRecord
.DataSource.ActiveRecord = wdFirstRecord
Do
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
sBrief = Path & "Test " & .DataFields(3).Value & ".docx"
End With
.Execute Pause:=False
If .DataSource.DataFields(3).Value > "" Then
ActiveDocument.SaveAs fileName:=sBrief, FileFormat:=wdFormatXMLDocument
End If
ActiveDocument.Close False
If .DataSource.ActiveRecord < LastRecord Then
.DataSource.ActiveRecord = wdNextRecord
Else
Exit Do
End If
Loop
End With
With ActiveDocument.MailMerge
.DataSource.ActiveRecord = wdLastRecord
LastRecord = .DataSource.ActiveRecord
.DataSource.ActiveRecord = wdFirstRecord
Do
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = .ActiveRecord
.LastRecord = .ActiveRecord
sBrief = Path & "Test " & .DataFields(3).Value & ".pdf"
End With
.Execute Pause:=False
If .DataSource.DataFields(3).Value > "" Then
ActiveDocument.SaveAs fileName:=sBrief, FileFormat:=wdFormatPDF
End If
ActiveDocument.Close False
If .DataSource.ActiveRecord < LastRecord Then
.DataSource.ActiveRecord = wdNextRecord
Else
Exit Do
End If
Loop
End With
End Sub |
Partager