View Single Post
 
Old 08-13-2021, 10:56 PM
RobertDany RobertDany is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Jul 2021
Posts: 22
RobertDany is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
You cannot use non-contiguous ranges with ExportAsFixedFormat you would need to use the PDF printer driver to achieve that.
Thank you Mr. gmayor for your comment and assistance

Dear gmayor,
I tried to edit your code, in order to save the file automatically under the current folder and name by using the following vars, but I failed (compile error syntax)

Code:
Dim CurrentFolder As String
Dim FileName As String

  myPath = ActiveDocument.FullName
  CurrentFolder = ActiveDocument.Path & "\"
  FileName = Mid(myPath, InStrRev(myPath, "\") + 1, _
   InStrRev(myPath, ".") - InStrRev(myPath, "\") - 1)
......

 Application.PrintOut FileName:="FileName",
Additionally, I edited my code according to your input box for continuous export but also failed (Invalid procedure or argument):

Code:
Sub SavePageRangeAsPDFffffff()

Dim sRange As String

sRange = InputBox("Enter the range of pages to be printed eg 1-3" & "")
    If sRange = "" Then
        MsgBox "No pages selected!", vbCritical, "Print Pages"
    End If
    
    ActiveDocument.ExportAsFixedFormat _
     OutputFileName:=CurrentFolder & "Robert" & ".pdf", _
     ExportFormat:=wdExportFormatPDF, _
     range:=sRange

End Sub
So I will be so appreciative for solving these two problems
Thank you again
Reply With Quote