Hello Friends;
why this code not work
I try to merge word and save result as PDF in one Macro
why this code not work
I try to merge word and save result as PDF in one Macro
Code:
Option Explicit
Public strFileName As String
Sub Make_PDF()
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ActiveDocument.ExportAsFixedFormat OutputFileName:=strFileName, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ChangeFileOpenDirectory "C:\Users\Azouz\Desktop\"
End Sub
Sub ShowOpen()
strFileName = ""
Const msoFileDialogFilePicker As Long = 3
Dim FD As Object
Set FD = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem As Variant
With FD
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "All Files", "*.PDF", 1
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
strFileName = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With