1*cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2*cdf0e10cSrcweir<helpdocument version="1.0"> 3*cdf0e10cSrcweir 4*cdf0e10cSrcweir<!-- 5*cdf0e10cSrcweir*********************************************************************** 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 12*cdf0e10cSrcweir * 13*cdf0e10cSrcweir * This file is part of OpenOffice.org. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 16*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 17*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 18*cdf0e10cSrcweir * 19*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 20*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 21*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 23*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 24*cdf0e10cSrcweir * 25*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 26*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 27*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 28*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 29*cdf0e10cSrcweir * 30*cdf0e10cSrcweir ************************************************************************ 31*cdf0e10cSrcweir --> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir<meta> 35*cdf0e10cSrcweir <topic id="textsharedguidescriptingxml" indexer="include"> 36*cdf0e10cSrcweir <title xml-lang="en-US" id="tit">Scripting %PRODUCTNAME</title> 37*cdf0e10cSrcweir <filename>/text/shared/guide/scripting.xhp</filename> 38*cdf0e10cSrcweir </topic> 39*cdf0e10cSrcweir </meta> 40*cdf0e10cSrcweir <body> 41*cdf0e10cSrcweir<bookmark xml-lang="en-US" branch="index" id="bm_id5277565"><bookmark_value>assigning scripts</bookmark_value> 42*cdf0e10cSrcweir <bookmark_value>programming;scripting</bookmark_value> 43*cdf0e10cSrcweir <bookmark_value>form controls;assigning macros</bookmark_value> 44*cdf0e10cSrcweir <bookmark_value>pictures;assigning macros</bookmark_value> 45*cdf0e10cSrcweir <bookmark_value>hyperlinks;assigning macros</bookmark_value> 46*cdf0e10cSrcweir <bookmark_value>shortcut keys;assigning macros</bookmark_value> 47*cdf0e10cSrcweir <bookmark_value>controls;assigning macros (Basic)</bookmark_value> 48*cdf0e10cSrcweir <bookmark_value>menus;assigning macros</bookmark_value> 49*cdf0e10cSrcweir <bookmark_value>events;assigning scripts</bookmark_value> 50*cdf0e10cSrcweir</bookmark><comment>MW deleted "programming;...", "scripting in programming", "BeanShell scripting", "Basic;..." and "java;..."</comment><comment>MW added "controls;..", "menus;..." and "events;..."</comment> 51*cdf0e10cSrcweir<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> 52*cdf0e10cSrcweir</variable></paragraph> 53*cdf0e10cSrcweir <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> 54*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1072B" role="paragraph" l10n="NEW">%PRODUCTNAME internally supports the following scripting languages:</paragraph> 55*cdf0e10cSrcweir <list type="ordered"> 56*cdf0e10cSrcweir <listitem> 57*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10731" role="paragraph" l10n="NEW">%PRODUCTNAME Basic</paragraph> 58*cdf0e10cSrcweir </listitem> 59*cdf0e10cSrcweir <listitem> 60*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10739" role="paragraph" l10n="NEW">JavaScript</paragraph> 61*cdf0e10cSrcweir </listitem> 62*cdf0e10cSrcweir <listitem> 63*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1073D" role="paragraph" l10n="CHG">BeanShell</paragraph> 64*cdf0e10cSrcweir </listitem> 65*cdf0e10cSrcweir <listitem> 66*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_id6797082" role="paragraph" l10n="CHG">Python</paragraph> 67*cdf0e10cSrcweir </listitem> 68*cdf0e10cSrcweir </list> 69*cdf0e10cSrcweir <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 OpenOffice.org.</paragraph> 70*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10751" role="heading" level="2" l10n="NEW">To assign a script to a new menu entry</paragraph> 71*cdf0e10cSrcweir <list type="ordered"> 72*cdf0e10cSrcweir <listitem> 73*cdf0e10cSrcweir <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> 74*cdf0e10cSrcweir </listitem> 75*cdf0e10cSrcweir <listitem> 76*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1093D" role="paragraph" l10n="NEW">Click <emph>Add</emph>.</paragraph> 77*cdf0e10cSrcweir </listitem> 78*cdf0e10cSrcweir <listitem> 79*cdf0e10cSrcweir <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> 80*cdf0e10cSrcweir </listitem> 81*cdf0e10cSrcweir <listitem> 82*cdf0e10cSrcweir <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> 83*cdf0e10cSrcweir </listitem> 84*cdf0e10cSrcweir <listitem> 85*cdf0e10cSrcweir <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> 86*cdf0e10cSrcweir </listitem> 87*cdf0e10cSrcweir <listitem> 88*cdf0e10cSrcweir <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> 89*cdf0e10cSrcweir </listitem> 90*cdf0e10cSrcweir <listitem> 91*cdf0e10cSrcweir <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> 92*cdf0e10cSrcweir </listitem> 93*cdf0e10cSrcweir </list> 94*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10783" role="heading" level="2" l10n="NEW">To assign a script to a key combination</paragraph> 95*cdf0e10cSrcweir <list type="ordered"> 96*cdf0e10cSrcweir <listitem> 97*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10787" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Keyboard</emph>.</paragraph> 98*cdf0e10cSrcweir </listitem> 99*cdf0e10cSrcweir <listitem> 100*cdf0e10cSrcweir <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> 101*cdf0e10cSrcweir </listitem> 102*cdf0e10cSrcweir <listitem> 103*cdf0e10cSrcweir <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> 104*cdf0e10cSrcweir </listitem> 105*cdf0e10cSrcweir <listitem> 106*cdf0e10cSrcweir <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> 107*cdf0e10cSrcweir </listitem> 108*cdf0e10cSrcweir <listitem> 109*cdf0e10cSrcweir <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> 110*cdf0e10cSrcweir </listitem> 111*cdf0e10cSrcweir <listitem> 112*cdf0e10cSrcweir <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> 113*cdf0e10cSrcweir <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> 114*cdf0e10cSrcweir </listitem> 115*cdf0e10cSrcweir <listitem> 116*cdf0e10cSrcweir <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> 117*cdf0e10cSrcweir </listitem> 118*cdf0e10cSrcweir </list> 119*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1078A" role="heading" level="2" l10n="NEW">To assign a script to an event</paragraph> 120*cdf0e10cSrcweir <list type="ordered"> 121*cdf0e10cSrcweir <listitem> 122*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1078E" role="paragraph" l10n="NEW">Choose <emph>Tools - Customize - Events</emph>.</paragraph> 123*cdf0e10cSrcweir </listitem> 124*cdf0e10cSrcweir <listitem> 125*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10A16" role="paragraph" l10n="NEW">Click <emph>Macro</emph> button.</paragraph> 126*cdf0e10cSrcweir </listitem> 127*cdf0e10cSrcweir <listitem> 128*cdf0e10cSrcweir <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> 129*cdf0e10cSrcweir </listitem> 130*cdf0e10cSrcweir <listitem> 131*cdf0e10cSrcweir <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> 132*cdf0e10cSrcweir </listitem> 133*cdf0e10cSrcweir <listitem> 134*cdf0e10cSrcweir <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> 135*cdf0e10cSrcweir </listitem> 136*cdf0e10cSrcweir <listitem> 137*cdf0e10cSrcweir <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> 138*cdf0e10cSrcweir </listitem> 139*cdf0e10cSrcweir <listitem> 140*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10AB6" role="paragraph" l10n="NEW">Select to save in %PRODUCTNAME or current document.</paragraph> 141*cdf0e10cSrcweir <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> 142*cdf0e10cSrcweir </listitem> 143*cdf0e10cSrcweir <listitem> 144*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10ABD" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 145*cdf0e10cSrcweir </listitem> 146*cdf0e10cSrcweir </list> 147*cdf0e10cSrcweir <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> 148*cdf0e10cSrcweir <list type="ordered"> 149*cdf0e10cSrcweir <listitem> 150*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10795" role="paragraph" l10n="NEW">Select the embedded object, for example a chart, in your document.</paragraph> 151*cdf0e10cSrcweir </listitem> 152*cdf0e10cSrcweir <listitem> 153*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10ADB" role="paragraph" l10n="NEW">Choose <emph>Format - Frame/Object - Macro</emph>.</paragraph> 154*cdf0e10cSrcweir </listitem> 155*cdf0e10cSrcweir <listitem> 156*cdf0e10cSrcweir <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> 157*cdf0e10cSrcweir </listitem> 158*cdf0e10cSrcweir <listitem> 159*cdf0e10cSrcweir <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> 160*cdf0e10cSrcweir </listitem> 161*cdf0e10cSrcweir <listitem> 162*cdf0e10cSrcweir <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> 163*cdf0e10cSrcweir </listitem> 164*cdf0e10cSrcweir <listitem> 165*cdf0e10cSrcweir <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> 166*cdf0e10cSrcweir </listitem> 167*cdf0e10cSrcweir <listitem> 168*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10AF7" role="paragraph" l10n="NEW">Select an event from the list and click <emph>OK</emph>.</paragraph> 169*cdf0e10cSrcweir </listitem> 170*cdf0e10cSrcweir </list> 171*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10798" role="heading" level="2" l10n="NEW">To assign a script to a hyperlink</paragraph> 172*cdf0e10cSrcweir <list type="ordered"> 173*cdf0e10cSrcweir <listitem> 174*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1079C" role="paragraph" l10n="NEW">Position the cursor inside the hyperlink. </paragraph> 175*cdf0e10cSrcweir </listitem> 176*cdf0e10cSrcweir <listitem> 177*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B15" role="paragraph" l10n="NEW">Choose <emph>Insert - Hyperlink</emph>.</paragraph> 178*cdf0e10cSrcweir </listitem> 179*cdf0e10cSrcweir <listitem> 180*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B19" role="paragraph" l10n="NEW">Click the <emph>Events</emph> button.</paragraph> 181*cdf0e10cSrcweir </listitem> 182*cdf0e10cSrcweir <listitem> 183*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B21" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 184*cdf0e10cSrcweir </listitem> 185*cdf0e10cSrcweir </list> 186*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN1079F" role="heading" level="2" l10n="NEW">To assign a script to a graphic</paragraph> 187*cdf0e10cSrcweir <list type="ordered"> 188*cdf0e10cSrcweir <listitem> 189*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN107A3" role="paragraph" l10n="NEW">Select the graphic in your document. </paragraph> 190*cdf0e10cSrcweir </listitem> 191*cdf0e10cSrcweir <listitem> 192*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B3B" role="paragraph" l10n="CHG">Choose <emph>Format - Picture - Macro</emph>.</paragraph> 193*cdf0e10cSrcweir </listitem> 194*cdf0e10cSrcweir <listitem> 195*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B3F" role="paragraph" l10n="NEW">Select and assign as stated above.</paragraph> 196*cdf0e10cSrcweir </listitem> 197*cdf0e10cSrcweir </list> 198*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN107A6" role="heading" level="2" l10n="NEW">To assign a script to a form control</paragraph> 199*cdf0e10cSrcweir <list type="ordered"> 200*cdf0e10cSrcweir <listitem> 201*cdf0e10cSrcweir <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> 202*cdf0e10cSrcweir </listitem> 203*cdf0e10cSrcweir <listitem> 204*cdf0e10cSrcweir <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> 205*cdf0e10cSrcweir </listitem> 206*cdf0e10cSrcweir <listitem> 207*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B5D" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 208*cdf0e10cSrcweir </listitem> 209*cdf0e10cSrcweir <listitem> 210*cdf0e10cSrcweir <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> 211*cdf0e10cSrcweir </listitem> 212*cdf0e10cSrcweir </list> 213*cdf0e10cSrcweir <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> 214*cdf0e10cSrcweir <list type="ordered"> 215*cdf0e10cSrcweir <listitem> 216*cdf0e10cSrcweir <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> 217*cdf0e10cSrcweir </listitem> 218*cdf0e10cSrcweir <listitem> 219*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B7F" role="paragraph" l10n="NEW">Right-click the control, then choose <emph>Properties</emph>.</paragraph> 220*cdf0e10cSrcweir </listitem> 221*cdf0e10cSrcweir <listitem> 222*cdf0e10cSrcweir <paragraph xml-lang="en-US" id="par_idN10B87" role="paragraph" l10n="NEW">Click the <emph>Events</emph> tab of the Properties dialog.</paragraph> 223*cdf0e10cSrcweir </listitem> 224*cdf0e10cSrcweir <listitem> 225*cdf0e10cSrcweir <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> 226*cdf0e10cSrcweir </listitem> 227*cdf0e10cSrcweir </list> 228*cdf0e10cSrcweir </body> 229*cdf0e10cSrcweir</helpdocument>