09-13-2016
07:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-13-2016
07:43 PM
The first argument to HasSaveCopyAsOptions should be the document, not the DataMedium object. Here's a version of your function that is working for me to print sheet 2 and 3.
Public Sub SaveAsPDF2(ByVal doc As Document)
' Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn
Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(doc, oContext, oOptions) Then
oOptions.value("All_Color_AS_Black") = 0
oOptions.value("Remove_Line_Weights") = 0
oOptions.value("Vector_Resolution") = 400
oOptions.value("Sheet_Range") = kPrintSheetRange
oOptions.value("Custom_Begin_Sheet") = 2
oOptions.value("Custom_End_Sheet") = 3
End If
'Set the destination file name
oDataMedium.filename = "c:\temp\test2.pdf"
'Publish document.
Call PDFAddIn.SaveCopyAs(doc, oContext, oOptions, oDataMedium)
End Sub
