need help
hi
i have macro would like to save all pages individually as pdf
But i get the same name on every PDF file. what do i have to change?
Sub SaveAsSeparatePDFs()
'UpdatebyExtendoffice20181120
Dim I As Long
Dim xDlg As FileDialog
Dim xFolder As Variant
Dim xStart, xEnd As Integer
Dim dateiname As String
On Error GoTo lbl
Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
If xDlg.Show <> -1 Then Exit Sub
xFolder = xDlg.SelectedItems(1)
xStart = CInt(InputBox("Start Page", "_"))
xEnd = CInt(InputBox("End Page:", "_"))
If xStart <= xEnd Then
For I = xStart To xEnd
With ActiveDocument
dateiname = .Range(Start:=.Paragraphs(1).Range.Start, End:=.Paragraphs(1).Range.End - 1).Text & "_"
Application.Browser.Target = wdBrowsePage
Application.Browser.Next
End With
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
dateiname & I & ".pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportFromTo, From:=I, To:=I, Item:=wdExportDocumentContent, _
IncludeDocProps:=False, KeepIRM:=False, CreateBookmarks:= _
wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=False, UseISO19005_1:=False
Next
End If
Exit Sub
lbl:
MsgBox "Enter right page number", vbInformation, "_"
End Sub
bes regard
|