Scriptable configs allow using JavaScript to customize the configuration. Only certain document functions implement this type of configuration and depending on the document function, other API objects may also be available.
Currently this concept is used in the document function Template Distribution.
Bedingungen
Elements can be restricted via the If
element. As with all (new) JavaScript APIs (e.g. Mappings or subtemplates), additional properties can be accessed via oo
API object. Analogous to Mappings, the condition can be defined as an attribute or as a subelement, as well as have an expression or a main function:
<!-- Expression in attribute --> <If Condition="oo.PowerPoint.Version == 15"> ... </If> <!-- Expression as subelement --> <If> <If.Condition>oo.PowerPoint.Version > 12</If.Condition> ... </If> <!-- Main function as subelement --> <If> <If.Condition> function main() { return oo.PowerPoint.Version > 12; } </If.Condition> ... </If>
Conditions can be nested in any way.
Examples
The following configuration:
<Configuration> <If Condition="oo.PowerPoint.Version == 14"> <Path>%APPDATA%\SomePowerpointAddin</Path> <If Condition="oo.PowerPoint.Is32Bit"> <Registry> <RegistryKey Root="HKCU" RegistryView="Registry32" Key="Software\Microsoft\Office\14.0\PowerPoint\AddIns\SomePowerpointAddin"> <RegistryValue Type="String" Name="Path" Expand="true">%APPDATA%\SomePowerpointAddin\SomePowerpointAddin.ppam</RegistryValue> <RegistryValue Type="DWord" Name="AutoLoad">00000001</RegistryValue> </RegistryKey> </Registry> </If> <If Condition="oo.PowerPoint.Is64Bit"> <Registry> <RegistryKey Root="HKCU" RegistryView="Registry64" Key="Software\Microsoft\Office\14.0\PowerPoint\AddIns\SomePowerpointAddin"> <RegistryValue Type="String" Name="Path" Expand="true">%APPDATA%\SomePowerpointAddin\SomePowerpointAddin.ppam</RegistryValue> <RegistryValue Type="DWord" Name="AutoLoad">00000001</RegistryValue> </RegistryKey> </Registry> </If> </If> </Configuration>
Results with API object: oo.PowerPoint.Version = 14
, oo.Is32Bit = true
and oo.Is64Bit = false
as follows:
<Configuration> <Path>%APPDATA%\SomePowerpointAddin</Path> <RegistryKey Root="HKCU" RegistryView="Registry32" Key="Software\Microsoft\Office\14.0\PowerPoint\AddIns\SomePowerpointAddin"> <RegistryValue Type="String" Name="Path" Expand="true">%APPDATA%\SomePowerpointAddin\SomePowerpointAddin.ppam</RegistryValue> <RegistryValue Type="DWord" Name="AutoLoad">00000001</RegistryValue> </RegistryKey> </Configuration>