第 1 条消息(共 3 条)
ShowSaveCopyAsOption does not work with options
As the title describes, could it be possible that ShowSaveCopyAsOption does not load the options that are provided with parameters?
If I do something like this:
Call PDFAddIn.ShowSaveCopyAsOptions( SourceObject, Context, Options)
then it looks like it doesnt matter what Options I provide. I was expection to see these reflected in the dialog, at least that is how I remember it working.
I especially set Options.Value("All_Color_AS_Black") = 1 so I was expecting to see this option checked inside the dialog.
Full code:
Sub GetPDFOptions()
Dim app As Application
Set app = ThisApplication
Dim addins As ApplicationAddIns
Set addins = app.ApplicationAddIns
' Get the DWF AddIn using its ID
Dim PDFAddIn As TranslatorAddIn
Set PDFAddIn = addins.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
' Activate AddIn
PDFAddIn.Activate
Dim SourceObject As Object
Dim Context As TranslationContext
Dim Options As NameValueMap
Dim transientObj As TransientObjects
Set transientObj = app.TransientObjects
Set Context = transientObj.CreateTranslationContext
Context.Type = kUnspecifiedIOMechanism
Set Options = transientObj.CreateNameValueMap
Set SourceObject = ThisApplication.ActiveDocument
Options.Value("All_Color_AS_Black") = 1
' Check if the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions( _
SourceObject, Context, Options) Then
' You can also show the Options dialog
' and then set whatever you need, then
' check here how those settings are stored
Call PDFAddIn.ShowSaveCopyAsOptions( _
SourceObject, Context, Options)
' Now print out the values
Call PrintInfo(Options, 1)
End If
End Sub
Sub PrintInfo(v As Variant, indent As Integer)
If TypeOf v Is NameValueMap Then
Dim nvm As NameValueMap
Set nvm = v
Dim i As Integer
For i = 1 To nvm.Count
Debug.Print Tab(indent); nvm.Name(i)
Call PrintInfo(nvm.Value(nvm.Name(i)), indent + 1)
Next
Else
Debug.Print Tab(indent); v
End If
End Sub