summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Lima <rafael.palma.lima@gmail.com>2021-07-10 17:06:46 +0200
committerOlivier Hallot <olivier.hallot@libreoffice.org>2021-07-12 14:12:24 +0200
commit19c8e31a7159740f3a2048e459b0237786d0a995 (patch)
treedfb569ec86f6b2de6a4272bc4a38fc2c815cb13f
parent0c56a2a24ba95bb5a8d39b8e647f5b9a52dd5648 (diff)
tdf#143211 Improve macro example in Validity check
Change-Id: Ic6a3db771731d21879897b2b6a45c5ce003e524e Reviewed-on: https://gerrit.libreoffice.org/c/help/+/118715 Tested-by: Jenkins Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r--source/text/scalc/01/12120300.xhp57
1 files changed, 35 insertions, 22 deletions
diff --git a/source/text/scalc/01/12120300.xhp b/source/text/scalc/01/12120300.xhp
index 771c03cc58..43da7d8c31 100644
--- a/source/text/scalc/01/12120300.xhp
+++ b/source/text/scalc/01/12120300.xhp
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-
-
<!--
* This file is part of the LibreOffice project.
*
@@ -21,20 +19,20 @@
<helpdocument version="1.0">
<meta>
-<topic id="textscalc0112120300xml" indexer="include" status="PUBLISH">
-<title id="tit" xml-lang="en-US">Error Alert</title>
-<filename>/text/scalc/01/12120300.xhp</filename>
-</topic>
-<history>
-<created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
-</history>
+ <topic id="textscalc0112120300xml" indexer="include" status="PUBLISH">
+ <title id="tit" xml-lang="en-US">Error Alert</title>
+ <filename>/text/scalc/01/12120300.xhp</filename>
+ </topic>
+ <history>
+ <created date="2003-10-31T00:00:00">Sun Microsystems, Inc.</created>
+ </history>
</meta>
<body>
<section id="fehlermeldung">
-<bookmark xml-lang="en-US" branch="hid/modules/scalc/ui/erroralerttabpage/ErrorAlertTabPage" id="bm_id3156024" localize="false"/>
-<bookmark xml-lang="en-US" branch="hid/modules/scalc/ui/erroralerttabpage/@@nowidget@@" id="bm_id3156024" localize="false"/>
-<paragraph role="heading" id="hd_id3153821" xml-lang="en-US" level="1"><link href="text/scalc/01/12120300.xhp" name="Error Alert">Error Alert</link></paragraph>
-<paragraph role="paragraph" id="par_id3153379" xml-lang="en-US"><ahelp hid="modules/scalc/ui/erroralerttabpage/ErrorAlertTabPage">Define the error message that is displayed when invalid data is entered in a cell.</ahelp></paragraph>
+ <bookmark xml-lang="en-US" branch="hid/modules/scalc/ui/erroralerttabpage/ErrorAlertTabPage" id="bm_id3156024" localize="false"/>
+ <bookmark xml-lang="en-US" branch="hid/modules/scalc/ui/erroralerttabpage/@@nowidget@@" id="bm_id3156024" localize="false"/>
+ <paragraph role="heading" id="hd_id3153821" xml-lang="en-US" level="1"><link href="text/scalc/01/12120300.xhp" name="Error Alert">Error Alert</link></paragraph>
+ <paragraph role="paragraph" id="par_id3153379" xml-lang="en-US"><ahelp hid="modules/scalc/ui/erroralerttabpage/ErrorAlertTabPage">Define the error message that is displayed when invalid data is entered in a cell.</ahelp></paragraph>
</section>
<paragraph role="paragraph" id="par_id3154138" xml-lang="en-US">You can also start a macro with an error message. A sample macro is provided at the end of this page.</paragraph>
<section id="howtoget">
@@ -58,15 +56,30 @@
<paragraph role="heading" id="hd_id3154510" xml-lang="en-US" level="3">Error message</paragraph>
<paragraph role="paragraph" id="par_id3149122" xml-lang="en-US"><ahelp hid="modules/scalc/ui/erroralerttabpage/errorMsg">Enter the message that you want to display when invalid data is entered in a cell.</ahelp></paragraph>
<section id="examplemakro">
-<h3 id="hd_id881545240342781">Sample macro:</h3>
-<bascode>
- <paragraph role="bascode" id="par_id31545240174027" xml-lang="en-US" localize="false">Function ExampleValidity(CellValue as String, TableCell as String)</paragraph>
- <paragraph role="bascode" id="par_id341545240202382" xml-lang="en-US" localize="false"> Dim msg as string</paragraph>
- <paragraph role="bascode" id="par_id11545240206618" xml-lang="en-US" localize="false"> msg = "Invalid value: " &amp; "'" &amp; CellValue &amp; "'"</paragraph>
- <paragraph role="bascode" id="par_id841545240210171" xml-lang="en-US" localize="false"> msg = msg &amp; " in table: " &amp; "'" &amp; TableCell &amp; "'"</paragraph>
- <paragraph role="bascode" id="par_id531545240216611" xml-lang="en-US" localize="false"> MsgBox msg ,16,"Error message"</paragraph>
- <paragraph role="bascode" id="par_id971545240220293" xml-lang="en-US" localize="false">End Function</paragraph>
-</bascode>
+ <h3 id="hd_id881545240342781">Sample macro:</h3>
+ <paragraph role="paragraph" id="par_id521625929022780">Below is a sample function that can be called when an error occurs. Note that the macro takes in two parameters that are passed on by %PRODUCTNAME when the function is called:</paragraph>
+ <list type="unordered">
+ <listitem>
+ <paragraph id="par_id981625929097216" role="listitem"><emph>CellValue</emph>: The value entered by the user, as a String.</paragraph>
+ </listitem>
+ <listitem>
+ <paragraph id="par_id421625929100152" role="listitem"><emph>CellAddress</emph>: The address of the cell where the value was entered, as a String prefixed with the sheet name (e.g: "Sheet1.A1").</paragraph>
+ </listitem>
+ </list>
+ <paragraph role="paragraph" id="par_id101625929384030">The function must return a Boolean value. If it returns <literal>True</literal>, the entered value is kept. If the function returns <literal>False</literal>, the entered value is erased and the previous value is restored.</paragraph>
+ <bascode>
+ <paragraph role="bascode" localize="false" id="par_id31545240174027">Function ExampleValidity(CellValue as String, CellAddress as String) as Boolean</paragraph>
+ <paragraph role="bascode" localize="false" id="par_id341545240202382"> Dim msg as String</paragraph>
+ <paragraph role="bascode" localize="false" id="par_id11545240206618"> Dim iAnswer as Integer</paragraph>
+ <paragraph role="bascode" localize="false" id="par_id841545240210171"> Dim MB_FLAGS as Integer</paragraph>
+ <paragraph role="bascode" id="par_id531545240216611"> msg = "Invalid value: " &amp; "'" &amp; CellValue &amp; "'"</paragraph>
+ <paragraph role="bascode" id="bas_id971625928577365"> msg = msg &amp; " in cell: " &amp; "'" &amp; CellAddress &amp; "'"</paragraph>
+ <paragraph role="bascode" id="bas_id181625928577640"> msg = msg &amp; Chr(10) &amp; "Accept anyway?"</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id711625928577798"> MB_FLAGS = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON2</paragraph>
+ <paragraph role="bascode" id="bas_id941625928578118"> iAnswer = MsgBox (msg , MB_FLAGS, "Error message")</paragraph>
+ <paragraph role="bascode" localize="false" id="bas_id11625928661345"> ExampleValidity = (iAnswer = IDYES)</paragraph>
+ <paragraph role="bascode" localize="false" id="par_id971545240220293">End Function</paragraph>
+ </bascode>
</section>
</body>
</helpdocument>