1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<helpdocument version="1.0"> 3*b1cdbd2cSJim Jagielski 4*b1cdbd2cSJim Jagielski<!--*********************************************************** 5*b1cdbd2cSJim Jagielski * 6*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 7*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 8*b1cdbd2cSJim Jagielski * distributed with this work for additional information 9*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 10*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 11*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 12*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 13*b1cdbd2cSJim Jagielski * 14*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 15*b1cdbd2cSJim Jagielski * 16*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 17*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 18*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 20*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 21*b1cdbd2cSJim Jagielski * under the License. 22*b1cdbd2cSJim Jagielski * 23*b1cdbd2cSJim Jagielski ***********************************************************--> 24*b1cdbd2cSJim Jagielski 25*b1cdbd2cSJim Jagielski 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski<meta> 29*b1cdbd2cSJim Jagielski <topic id="textsharedguidescriptingxml" indexer="include"> 30*b1cdbd2cSJim Jagielski <title xml-lang="en-US" id="tit">Scripting %PRODUCTNAME</title> 31*b1cdbd2cSJim Jagielski <filename>/text/shared/guide/scripting.xhp</filename> 32*b1cdbd2cSJim Jagielski </topic> 33*b1cdbd2cSJim Jagielski </meta> 34*b1cdbd2cSJim Jagielski <body> 35*b1cdbd2cSJim Jagielski<bookmark xml-lang="en-US" branch="index" id="bm_id5277565"><bookmark_value>assigning scripts</bookmark_value> 36*b1cdbd2cSJim Jagielski <bookmark_value>programming;scripting</bookmark_value> 37*b1cdbd2cSJim Jagielski <bookmark_value>form controls;assigning macros</bookmark_value> 38*b1cdbd2cSJim Jagielski <bookmark_value>pictures;assigning macros</bookmark_value> 39*b1cdbd2cSJim Jagielski <bookmark_value>hyperlinks;assigning macros</bookmark_value> 40*b1cdbd2cSJim Jagielski <bookmark_value>shortcut keys;assigning macros</bookmark_value> 41*b1cdbd2cSJim Jagielski <bookmark_value>controls;assigning macros (Basic)</bookmark_value> 42*b1cdbd2cSJim Jagielski <bookmark_value>menus;assigning macros</bookmark_value> 43*b1cdbd2cSJim Jagielski <bookmark_value>events;assigning scripts</bookmark_value> 44*b1cdbd2cSJim Jagielski</bookmark><comment>MW deleted "programming;...", "scripting in programming", "BeanShell scripting", "Basic;..." and "java;..."</comment><comment>MW added "controls;..", "menus;..." and "events;..."</comment> 45*b1cdbd2cSJim Jagielski<paragraph xml-lang="en-US" id="par_idN1070A" role="heading" level="1" l10n="NEW"><variable id="scripting"><link href="text/shared/guide/scripting.xhp">Assigning Scripts in %PRODUCTNAME</link> 46*b1cdbd2cSJim Jagielski</variable></paragraph> 47*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10728" role="paragraph" l10n="NEW">You can assign custom scripts (macros) to menu items, icons, dialog controls, and events in %PRODUCTNAME.</paragraph> 48*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1072B" role="paragraph" l10n="NEW">%PRODUCTNAME internally supports the following scripting languages:</paragraph> 49*b1cdbd2cSJim Jagielski <list type="ordered"> 50*b1cdbd2cSJim Jagielski <listitem> 51*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10731" role="paragraph" l10n="NEW">%PRODUCTNAME Basic</paragraph> 52*b1cdbd2cSJim Jagielski </listitem> 53*b1cdbd2cSJim Jagielski <listitem> 54*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10739" role="paragraph" l10n="NEW">JavaScript</paragraph> 55*b1cdbd2cSJim Jagielski </listitem> 56*b1cdbd2cSJim Jagielski <listitem> 57*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1073D" role="paragraph" l10n="CHG">BeanShell</paragraph> 58*b1cdbd2cSJim Jagielski </listitem> 59*b1cdbd2cSJim Jagielski <listitem> 60*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_id6797082" role="paragraph" l10n="CHG">Python</paragraph> 61*b1cdbd2cSJim Jagielski </listitem> 62*b1cdbd2cSJim Jagielski </list> 63*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1091F" role="paragraph" l10n="NEW">In addition, developers can use high-level languages, for example Java programming language, to control %PRODUCTNAME externally. See the API project at Apache OpenOffice.</paragraph> 64*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10751" role="heading" level="2" l10n="NEW">To assign a script to a new menu entry</paragraph> 65*b1cdbd2cSJim Jagielski <list type="ordered"> 66*b1cdbd2cSJim Jagielski <listitem> 67*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10758" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize</emph>, and click the <emph>Menus</emph> tab.</paragraph> 68*b1cdbd2cSJim Jagielski </listitem> 69*b1cdbd2cSJim Jagielski <listitem> 70*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1093D" role="paragraph" l10n="NEW">Click <emph>Add</emph>.</paragraph> 71*b1cdbd2cSJim Jagielski </listitem> 72*b1cdbd2cSJim Jagielski <listitem> 73*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10760" role="paragraph" l10n="NEW">In the <emph>Category</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 74*b1cdbd2cSJim Jagielski </listitem> 75*b1cdbd2cSJim Jagielski <listitem> 76*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10768" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 77*b1cdbd2cSJim Jagielski </listitem> 78*b1cdbd2cSJim Jagielski <listitem> 79*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1076C" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select a script.</paragraph> 80*b1cdbd2cSJim Jagielski </listitem> 81*b1cdbd2cSJim Jagielski <listitem> 82*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10770" role="paragraph" l10n="NEW">A list of the script functions appears in the <emph>Commands</emph> list box. Select a function.</paragraph> 83*b1cdbd2cSJim Jagielski </listitem> 84*b1cdbd2cSJim Jagielski <listitem> 85*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10778" role="paragraph" l10n="NEW">Click <emph>Add</emph> to create a new menu assignment. The new menu entry appears in the <emph>Entries</emph> list box.</paragraph> 86*b1cdbd2cSJim Jagielski </listitem> 87*b1cdbd2cSJim Jagielski </list> 88*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10783" role="heading" level="2" l10n="NEW">To assign a script to a key combination</paragraph> 89*b1cdbd2cSJim Jagielski <list type="ordered"> 90*b1cdbd2cSJim Jagielski <listitem> 91*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10787" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Keyboard</emph>.</paragraph> 92*b1cdbd2cSJim Jagielski </listitem> 93*b1cdbd2cSJim Jagielski <listitem> 94*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A59" role="paragraph" l10n="NEW">In the <emph>Category</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 95*b1cdbd2cSJim Jagielski </listitem> 96*b1cdbd2cSJim Jagielski <listitem> 97*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A61" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 98*b1cdbd2cSJim Jagielski </listitem> 99*b1cdbd2cSJim Jagielski <listitem> 100*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A65" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 101*b1cdbd2cSJim Jagielski </listitem> 102*b1cdbd2cSJim Jagielski <listitem> 103*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A69" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Commands</emph> list box. Select any function.</paragraph> 104*b1cdbd2cSJim Jagielski </listitem> 105*b1cdbd2cSJim Jagielski <listitem> 106*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A71" role="paragraph" l10n="NEW">Click the option button for %PRODUCTNAME or Writer (or whichever application is currently open). </paragraph> 107*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A74" role="paragraph" l10n="NEW">Selecting the option button sets the scope of the new key combination to be applicable in all of %PRODUCTNAME or only in documents of the current module.</paragraph> 108*b1cdbd2cSJim Jagielski </listitem> 109*b1cdbd2cSJim Jagielski <listitem> 110*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A78" role="paragraph" l10n="NEW">Select a key combination from the <emph>Shortcut keys</emph> list box and click <emph>Modify</emph>.</paragraph> 111*b1cdbd2cSJim Jagielski </listitem> 112*b1cdbd2cSJim Jagielski </list> 113*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1078A" role="heading" level="2" l10n="NEW">To assign a script to an event</paragraph> 114*b1cdbd2cSJim Jagielski <list type="ordered"> 115*b1cdbd2cSJim Jagielski <listitem> 116*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1078E" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Events</emph>.</paragraph> 117*b1cdbd2cSJim Jagielski </listitem> 118*b1cdbd2cSJim Jagielski <listitem> 119*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A16" role="paragraph" l10n="NEW">Click <emph>Macro</emph> button.</paragraph> 120*b1cdbd2cSJim Jagielski </listitem> 121*b1cdbd2cSJim Jagielski <listitem> 122*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10A9E" role="paragraph" l10n="NEW">In the <emph>Library</emph> list box, scroll down and open the "%PRODUCTNAME Macros" entry.</paragraph> 123*b1cdbd2cSJim Jagielski </listitem> 124*b1cdbd2cSJim Jagielski <listitem> 125*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AA6" role="paragraph" l10n="NEW">You see entries for "%PRODUCTNAME Macros" (scripts in the share directory of your %PRODUCTNAME installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 126*b1cdbd2cSJim Jagielski </listitem> 127*b1cdbd2cSJim Jagielski <listitem> 128*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AAA" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 129*b1cdbd2cSJim Jagielski </listitem> 130*b1cdbd2cSJim Jagielski <listitem> 131*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AAE" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Assigned Action</emph> list box. Select any function.</paragraph> 132*b1cdbd2cSJim Jagielski </listitem> 133*b1cdbd2cSJim Jagielski <listitem> 134*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AB6" role="paragraph" l10n="NEW">Select to save in %PRODUCTNAME or current document.</paragraph> 135*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AB9" role="paragraph" l10n="CHG">This sets the scope of the new event assignment to be applicable in all of %PRODUCTNAME or only in documents of the current module.</paragraph> 136*b1cdbd2cSJim Jagielski </listitem> 137*b1cdbd2cSJim Jagielski <listitem> 138*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10ABD" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 139*b1cdbd2cSJim Jagielski </listitem> 140*b1cdbd2cSJim Jagielski </list> 141*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10791" role="heading" level="2" l10n="NEW">To assign a script to an event for an embedded object</paragraph> 142*b1cdbd2cSJim Jagielski <list type="ordered"> 143*b1cdbd2cSJim Jagielski <listitem> 144*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10795" role="paragraph" l10n="NEW">Select the embedded object, for example a chart, in your document.</paragraph> 145*b1cdbd2cSJim Jagielski </listitem> 146*b1cdbd2cSJim Jagielski <listitem> 147*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10ADB" role="paragraph" l10n="NEW">Choose <emph>Format - Frame/Object - Macro</emph>.</paragraph> 148*b1cdbd2cSJim Jagielski </listitem> 149*b1cdbd2cSJim Jagielski <listitem> 150*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10ADF" role="paragraph" l10n="NEW">In the <emph>Macros</emph> list box, open the %PRODUCTNAME Scripts entry.</paragraph> 151*b1cdbd2cSJim Jagielski </listitem> 152*b1cdbd2cSJim Jagielski <listitem> 153*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AE7" role="paragraph" l10n="NEW">You see entries for share (scripts in the share directory of your %PRODUCTNAME installation), user (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.</paragraph> 154*b1cdbd2cSJim Jagielski </listitem> 155*b1cdbd2cSJim Jagielski <listitem> 156*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AEB" role="paragraph" l10n="NEW">Open any scripting language entry to see the available scripts. Select any script.</paragraph> 157*b1cdbd2cSJim Jagielski </listitem> 158*b1cdbd2cSJim Jagielski <listitem> 159*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AEF" role="paragraph" l10n="NEW">A list of the script functions will appear in the <emph>Existing macros in</emph> list box. Select any function.</paragraph> 160*b1cdbd2cSJim Jagielski </listitem> 161*b1cdbd2cSJim Jagielski <listitem> 162*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10AF7" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 163*b1cdbd2cSJim Jagielski </listitem> 164*b1cdbd2cSJim Jagielski </list> 165*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10798" role="heading" level="2" l10n="NEW">To assign a script to a hyperlink</paragraph> 166*b1cdbd2cSJim Jagielski <list type="ordered"> 167*b1cdbd2cSJim Jagielski <listitem> 168*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1079C" role="paragraph" l10n="NEW">Position the cursor inside the hyperlink. </paragraph> 169*b1cdbd2cSJim Jagielski </listitem> 170*b1cdbd2cSJim Jagielski <listitem> 171*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B15" role="paragraph" l10n="NEW">Choose <emph>Insert - Hyperlink</emph>.</paragraph> 172*b1cdbd2cSJim Jagielski </listitem> 173*b1cdbd2cSJim Jagielski <listitem> 174*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B19" role="paragraph" l10n="NEW">Click the <emph>Events</emph> button.</paragraph> 175*b1cdbd2cSJim Jagielski </listitem> 176*b1cdbd2cSJim Jagielski <listitem> 177*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B21" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 178*b1cdbd2cSJim Jagielski </listitem> 179*b1cdbd2cSJim Jagielski </list> 180*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN1079F" role="heading" level="2" l10n="NEW">To assign a script to a graphic</paragraph> 181*b1cdbd2cSJim Jagielski <list type="ordered"> 182*b1cdbd2cSJim Jagielski <listitem> 183*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN107A3" role="paragraph" l10n="NEW">Select the graphic in your document. </paragraph> 184*b1cdbd2cSJim Jagielski </listitem> 185*b1cdbd2cSJim Jagielski <listitem> 186*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B3B" role="paragraph" l10n="CHG">Choose <emph>Format - Picture - Macro</emph>.</paragraph> 187*b1cdbd2cSJim Jagielski </listitem> 188*b1cdbd2cSJim Jagielski <listitem> 189*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B3F" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 190*b1cdbd2cSJim Jagielski </listitem> 191*b1cdbd2cSJim Jagielski </list> 192*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN107A6" role="heading" level="2" l10n="NEW">To assign a script to a form control</paragraph> 193*b1cdbd2cSJim Jagielski <list type="ordered"> 194*b1cdbd2cSJim Jagielski <listitem> 195*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN107AA" role="paragraph" l10n="CHG">Insert a form control, for example a button: Open the Form Controls toolbar, click the <emph>Push Button</emph> icon, drag open a button on your document.</paragraph> 196*b1cdbd2cSJim Jagielski </listitem> 197*b1cdbd2cSJim Jagielski <listitem> 198*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B59" role="paragraph" l10n="CHG">With the form control selected, click <emph>Control</emph> on the Form Controls toolbar.</paragraph> 199*b1cdbd2cSJim Jagielski </listitem> 200*b1cdbd2cSJim Jagielski <listitem> 201*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B5D" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 202*b1cdbd2cSJim Jagielski </listitem> 203*b1cdbd2cSJim Jagielski <listitem> 204*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B61" role="paragraph" l10n="NEW">Click one of the <emph>...</emph> buttons to open a dialog where you can assign a script to the selected event.</paragraph> 205*b1cdbd2cSJim Jagielski </listitem> 206*b1cdbd2cSJim Jagielski </list> 207*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN107AD" role="heading" level="2" l10n="NEW">To assign a script to a control in the %PRODUCTNAME Basic dialog</paragraph> 208*b1cdbd2cSJim Jagielski <list type="ordered"> 209*b1cdbd2cSJim Jagielski <listitem> 210*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN107B1" role="paragraph" l10n="NEW">Open the %PRODUCTNAME Basic dialog editor, then create a dialog with a control on it.</paragraph> 211*b1cdbd2cSJim Jagielski </listitem> 212*b1cdbd2cSJim Jagielski <listitem> 213*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B7F" role="paragraph" l10n="NEW">Right-click the control, then choose <emph>Properties</emph>.</paragraph> 214*b1cdbd2cSJim Jagielski </listitem> 215*b1cdbd2cSJim Jagielski <listitem> 216*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B87" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 217*b1cdbd2cSJim Jagielski </listitem> 218*b1cdbd2cSJim Jagielski <listitem> 219*b1cdbd2cSJim Jagielski <paragraph xml-lang="en-US" id="par_idN10B8B" role="paragraph" l10n="NEW">Click one of the <emph>...</emph> buttons to open a dialog where you can assign a script to the selected event.</paragraph> 220*b1cdbd2cSJim Jagielski </listitem> 221*b1cdbd2cSJim Jagielski </list> 222*b1cdbd2cSJim Jagielski </body> 223*b1cdbd2cSJim Jagielski</helpdocument>