1<?xml version="1.0" encoding="UTF-8"?> 2<helpdocument version="1.0"> 3 4<!--*********************************************************** 5 * 6 * Licensed to the Apache Software Foundation (ASF) under one 7 * or more contributor license agreements. See the NOTICE file 8 * distributed with this work for additional information 9 * regarding copyright ownership. The ASF licenses this file 10 * to you under the Apache License, Version 2.0 (the 11 * "License"); you may not use this file except in compliance 12 * with the License. You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, 17 * software distributed under the License is distributed on an 18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 * KIND, either express or implied. See the License for the 20 * specific language governing permissions and limitations 21 * under the License. 22 * 23 ***********************************************************--> 24 25 26 27 28<meta> 29 <topic id="textsbasicshared01040000xml" indexer="include" status="PUBLISH"> 30 <title xml-lang="en-US" id="tit">Event-Driven Macros</title> 31 <filename>/text/sbasic/shared/01040000.xhp</filename> 32 </topic> 33 </meta> 34 <body> 35 <section id="weitere"> 36<bookmark xml-lang="en-US" branch="index" id="bm_id3154581"><bookmark_value>deleting; macro assignments to events</bookmark_value> 37 <bookmark_value>macros; assigning to events</bookmark_value> 38 <bookmark_value>assigning macros to events</bookmark_value> 39 <bookmark_value>events; assigning macros</bookmark_value> 40</bookmark> 41<paragraph xml-lang="en-US" id="hd_id3147348" role="heading" level="1" l10n="U" oldref="1"><link href="text/sbasic/shared/01040000.xhp" name="Event-Driven Macros">Event-Driven Macros</link></paragraph> 42 <paragraph xml-lang="en-US" id="par_id3146120" role="paragraph" l10n="U" oldref="2">This section describes how to assign Basic programs to program events.</paragraph> 43 </section> 44 <paragraph xml-lang="en-US" id="par_id3149263" role="paragraph" l10n="U" oldref="4">You can automatically execute a macro when a specified software event occurs by assigning the desired macro to the event. The following table provides an overview of program events and at what point an assigned macro is executed.</paragraph> 45 <table id="tbl_id3148646"> 46 <tablerow> 47 <tablecell> 48 <paragraph xml-lang="en-US" id="par_id3148455" role="tablehead" l10n="U" oldref="5">Event</paragraph> 49 </tablecell> 50 <tablecell> 51 <paragraph xml-lang="en-US" id="par_id3145799" role="tablehead" l10n="U" oldref="6">An assigned macro is executed...</paragraph> 52 </tablecell> 53 </tablerow> 54 <tablerow> 55 <tablecell> 56 <paragraph xml-lang="en-US" id="par_id3149379" role="tablecontent" l10n="U" oldref="7">Program Start</paragraph> 57 </tablecell> 58 <tablecell> 59 <paragraph xml-lang="en-US" id="par_id3150715" role="tablecontent" l10n="U" oldref="8">... after a $[officename] application is started.</paragraph> 60 </tablecell> 61 </tablerow> 62 <tablerow> 63 <tablecell> 64 <paragraph xml-lang="en-US" id="par_id3146914" role="tablecontent" l10n="U" oldref="9">Program End</paragraph> 65 </tablecell> 66 <tablecell> 67 <paragraph xml-lang="en-US" id="par_id3153765" role="tablecontent" l10n="U" oldref="10">...before a $[officename] application is terminated.</paragraph> 68 </tablecell> 69 </tablerow> 70 <tablerow> 71 <tablecell> 72 <paragraph xml-lang="en-US" id="par_id3145150" role="tablecontent" l10n="U" oldref="11">Create Document</paragraph> 73 </tablecell> 74 <tablecell> 75 <paragraph xml-lang="en-US" id="par_id3163808" role="tablecontent" l10n="U" oldref="12">...after a new document is created with <emph>File - New</emph> or with the <emph>New</emph> icon.</paragraph> 76 </tablecell> 77 </tablerow> 78 <tablerow> 79 <tablecell> 80 <paragraph xml-lang="en-US" id="par_id3145790" role="tablecontent" l10n="U" oldref="13">Open Document</paragraph> 81 </tablecell> 82 <tablecell> 83 <paragraph xml-lang="en-US" id="par_id3154572" role="tablecontent" l10n="U" oldref="14">...after a document is opened with <emph>File - Open</emph> or with the <emph>Open</emph> icon.</paragraph> 84 </tablecell> 85 </tablerow> 86 <tablerow> 87 <tablecell> 88 <paragraph xml-lang="en-US" id="par_id3153266" role="tablecontent" l10n="U" oldref="15">Save Document As</paragraph> 89 </tablecell> 90 <tablecell> 91 <paragraph xml-lang="en-US" id="par_id3150208" role="tablecontent" l10n="U" oldref="16">...before a document is saved under a specified name (with <emph>File - Save As</emph>, or with <emph>File - Save</emph> or the <emph>Save</emph> icon, if a document name has not yet been specified).</paragraph> 92 </tablecell> 93 </tablerow> 94 <tablerow> 95 <tablecell> 96 <paragraph xml-lang="en-US" id="par_id3158215" role="tablecontent" l10n="U" oldref="43">Document has been saved as</paragraph> 97 </tablecell> 98 <tablecell> 99 <paragraph xml-lang="en-US" id="par_id3150980" role="tablecontent" l10n="U" oldref="44">... after a document was saved under a specified name (with <emph>File - Save As</emph>, or with <emph>File - Save</emph> or with the <emph>Save</emph> icon, if a document name has not yet been specified).</paragraph> 100 </tablecell> 101 </tablerow> 102 <tablerow> 103 <tablecell> 104 <paragraph xml-lang="en-US" id="par_id3150519" role="tablecontent" l10n="U" oldref="17">Save Document</paragraph> 105 </tablecell> 106 <tablecell> 107 <paragraph xml-lang="en-US" id="par_id3155529" role="tablecontent" l10n="U" oldref="18">...before a document is saved with <emph>File - Save</emph> or the <emph>Save</emph> icon, provided that a document name has already been specified.</paragraph> 108 </tablecell> 109 </tablerow> 110 <tablerow> 111 <tablecell> 112 <paragraph xml-lang="en-US" id="par_id3149404" role="tablecontent" l10n="U" oldref="45">Document has been saved</paragraph> 113 </tablecell> 114 <tablecell> 115 <paragraph xml-lang="en-US" id="par_id3151332" role="tablecontent" l10n="U" oldref="46">...after a document is saved with <emph>File - Save</emph> or the <emph>Save</emph> icon, provided that a document name has already been specified.</paragraph> 116 </tablecell> 117 </tablerow> 118 <tablerow> 119 <tablecell> 120 <paragraph xml-lang="en-US" id="par_id3159171" role="tablecontent" l10n="CHG" oldref="19">Document is closing<comment>i104852</comment></paragraph> 121 </tablecell> 122 <tablecell> 123 <paragraph xml-lang="en-US" id="par_id3146868" role="tablecontent" l10n="U" oldref="20">...before a document is closed.</paragraph> 124 </tablecell> 125 </tablerow> 126 <tablerow> 127 <tablecell> 128 <paragraph xml-lang="en-US" id="par_id3159097" role="tablecontent" l10n="CHG" oldref="47">Document closed</paragraph> 129 </tablecell> 130 <tablecell> 131 <paragraph xml-lang="en-US" id="par_id3148606" role="tablecontent" l10n="U" oldref="48">...after a document was closed. Note that the "Save Document" event may also occur when the document is saved before closing.</paragraph> 132 </tablecell> 133 </tablerow> 134 <tablerow> 135 <tablecell> 136 <paragraph xml-lang="en-US" id="par_id3144772" role="tablecontent" l10n="U" oldref="21">Activate Document</paragraph> 137 </tablecell> 138 <tablecell> 139 <paragraph xml-lang="en-US" id="par_id3149442" role="tablecontent" l10n="U" oldref="22">...after a document is brought to the foreground.</paragraph> 140 </tablecell> 141 </tablerow> 142 <tablerow> 143 <tablecell> 144 <paragraph xml-lang="en-US" id="par_id3150888" role="tablecontent" l10n="U" oldref="23">Deactivate Document</paragraph> 145 </tablecell> 146 <tablecell> 147 <paragraph xml-lang="en-US" id="par_id3154060" role="tablecontent" l10n="U" oldref="24">...after another document is brought to the foreground.</paragraph> 148 </tablecell> 149 </tablerow> 150 <tablerow> 151 <tablecell> 152 <paragraph xml-lang="en-US" id="par_id3152384" role="tablecontent" l10n="U" oldref="25">Print Document</paragraph> 153 </tablecell> 154 <tablecell> 155 <paragraph xml-lang="en-US" id="par_id3152873" role="tablecontent" l10n="U" oldref="26">...after the <emph>Print</emph> dialog is closed, but before the actual print process begins.</paragraph> 156 </tablecell> 157 </tablerow> 158 <tablerow> 159 <tablecell> 160 <paragraph xml-lang="en-US" id="par_id3159227" role="tablecontent" l10n="U" oldref="49">JavaScript run-time error</paragraph> 161 </tablecell> 162 <tablecell> 163 <paragraph xml-lang="en-US" id="par_id3145362" role="tablecontent" l10n="U" oldref="50">...when a JavaScript run-time error occurs.</paragraph> 164 </tablecell> 165 </tablerow> 166 <tablerow> 167 <tablecell> 168 <paragraph xml-lang="en-US" id="par_id3154767" role="tablecontent" l10n="U" oldref="27">Print Mail Merge</paragraph> 169 </tablecell> 170 <tablecell> 171 <paragraph xml-lang="en-US" id="par_id3153555" role="tablecontent" l10n="U" oldref="28">...after the <emph>Print</emph> dialog is closed, but before the actual print process begins. This event occurs for each copy printed.</paragraph> 172 </tablecell> 173 </tablerow> 174 <tablerow> 175 <tablecell> 176 <paragraph xml-lang="en-US" id="par_id3156366" role="tablecontent" l10n="U" oldref="51">Change of the page count</paragraph> 177 </tablecell> 178 <tablecell> 179 <paragraph xml-lang="en-US" id="par_id3154627" role="tablecontent" l10n="U" oldref="52">...when the page count changes.</paragraph> 180 </tablecell> 181 </tablerow> 182 <tablerow> 183 <tablecell> 184 <paragraph xml-lang="en-US" id="par_id3154737" role="tablecontent" l10n="U" oldref="53">Message received</paragraph> 185 </tablecell> 186 <tablecell> 187 <paragraph xml-lang="en-US" id="par_id3150952" role="tablecontent" l10n="U" oldref="54">...if a message was received.</paragraph> 188 </tablecell> 189 </tablerow> 190 </table> 191 192 <paragraph xml-lang="en-US" id="hd_id3153299" role="heading" level="2" l10n="U" 193 oldref="30">Assigning a Macro to an Event</paragraph> 194 <list type="ordered"> 195 <listitem> 196 <paragraph xml-lang="en-US" id="par_id3147244" role="listitem" l10n="U" oldref="31">Choose <emph>Tools - Customize</emph> and click the <emph>Events</emph> tab.</paragraph> 197 </listitem> 198 <listitem> 199 <paragraph xml-lang="en-US" id="par_id3146098" role="listitem" l10n="CHG" oldref="55">Select whether you want the assignment to be globally valid or just valid in the current document in the <emph>Save In</emph> listbox.</paragraph> 200 </listitem> 201 <listitem> 202 <paragraph xml-lang="en-US" id="par_id3150431" role="listitem" l10n="U" oldref="32">Select the event from the <emph>Event</emph> list.</paragraph> 203 </listitem> 204 <listitem> 205 <paragraph xml-lang="en-US" id="par_id3148742" role="listitem" l10n="CHG" oldref="33">Click <emph>Macro</emph> and select the macro to be assigned to the selected event.</paragraph> 206 </listitem> 207 <listitem> 208 <paragraph xml-lang="en-US" id="par_id3146321" role="listitem" l10n="CHG" oldref="35">Click <emph>OK</emph> to assign the macro.</paragraph> 209 </listitem> 210 <listitem> 211 <paragraph xml-lang="en-US" id="par_id3147414" role="listitem" l10n="U" oldref="56">Click <emph>OK</emph> to close the dialog.</paragraph> 212 </listitem> 213 </list> 214 <paragraph xml-lang="en-US" id="hd_id3154581" role="heading" level="2" l10n="U" 215 oldref="36">Removing the Assignment of a Macro to an Event</paragraph> 216 <list type="ordered"> 217 <listitem> 218 <paragraph xml-lang="en-US" id="par_id3146883" role="listitem" l10n="U" oldref="57">Choose <emph>Tools - Customize</emph> and click the <emph>Events</emph> tab.</paragraph> 219 </listitem> 220 <listitem> 221 <paragraph xml-lang="en-US" id="par_id3155909" role="listitem" l10n="CHG" oldref="58">Select whether you want to remove a global assignment or an assignment that is just valid in the current document by selecting the option in the <emph>Save In</emph> listbox.</paragraph> 222 </listitem> 223 <listitem> 224 <paragraph xml-lang="en-US" id="par_id3159129" role="listitem" l10n="U" oldref="59">Select the event that contains the assignment to be removed from the <emph>Event</emph> list.</paragraph> 225 </listitem> 226 <listitem> 227 <paragraph xml-lang="en-US" id="par_id3149143" role="listitem" l10n="U" oldref="37">Click <emph>Remove</emph>.</paragraph> 228 </listitem> 229 <listitem> 230 <paragraph xml-lang="en-US" id="par_id3149351" role="listitem" l10n="U" oldref="60">Click <emph>OK</emph> to close the dialog.</paragraph> 231 </listitem> 232 </list> 233 </body> 234</helpdocument>