Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-23-2021, 02:03 PM
Anatoli740 Anatoli740 is offline need help Windows 10 need help Office 2019
Novice
need help
 
Join Date: Jan 2021
Posts: 3
Anatoli740 is on a distinguished road
Default 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
Reply With Quote
 



Other Forums: Access Forums

All times are GMT -7. The time now is 11:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft