Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 01-23-2021, 11:57 PM
gmayor's Avatar
gmayor gmayor is offline need help Windows 10 need help Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The process saves numbered versions of the first paragraph of the document as the filename. The code also selects a path then doesn't use it?

If this is the output of a mail merge - see Merge and Split which will split it to PDF files, or better still use it to merge to PDF files.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 01-24-2021, 02:57 AM
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

hi

i have installed your programm
Reply With Quote
  #4  
Old 01-24-2021, 04:04 AM
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

your programm work!!!
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 AM.


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