<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Servicio ScriptForge.UI</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="es/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="es/bookmarks.js" defer></script><script type="text/javascript" src="es/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="es/text/shared/05/new_help.html"><div></div></a><a class="logo" href="es/text/shared/05/new_help.html"><p dir="auto">Ayuda de LibreOffice 25.2</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Módulo</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contenido</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Buscar en los marcadores del módulo elegido" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<noscript><div id="WarnJS"><h1 dir="auto">Active JavaScript en el navegador para mostrar las páginas de ayuda de LibreOffice.</h1></div></noscript>
<a id="abstract"></a>
<a id="bm_id151587913266190"></a>
<meta itemprop="keywords" content="UI service">
<h1 id="hd_id371587913266310" dir="auto">
<a id="UIService"></a>Servicio <span class="literal">ScriptForge</span>.<span class="literal">UI</span>
</h1>
<p id="par_id31587913266153" class="paragraph" dir="auto">El servicio UI (del inglés, interfaz de usuario) simplifica la identificación y la manipulación de las diferentes ventanas que componen la aplicación LibreOffice en su conjunto:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id591587913266547" class="listitem" dir="auto">Selección de ventanas</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id511587913266292" class="listitem" dir="auto">Redimensionamiento y traslado de ventanas</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id51587913266596" class="listitem" dir="auto">Configuración de la barra de estado</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id401599404339702" class="listitem" dir="auto">Presentación de una barra de progreso flotante</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id761587913266388" class="listitem" dir="auto">Creación de ventanas nuevas</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id591587913266489" class="listitem" dir="auto">Acceso a los «documentos» subyacentes</p>
</li>
</ul>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id181620312953395" dir="auto">The UI service is the starting point to open, create or access to the content of new or existing documents from a user script.</p></div>
</div>
<br>
<h2 id="hd_id881587913266307" dir="auto">Definiciones</h2>
<a id="WindowName"></a>
<h3 id="hd_id761587913266887" dir="auto">WindowName</h3>
<p id="par_id741587913266919" class="paragraph" dir="auto">A window can be designated using various ways:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id291587913946648" class="listitem" dir="auto">a full path and file name</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id991587914045862" class="listitem" dir="auto">the last component of the full file name or even only the last component without its suffix</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id541587914079744" class="listitem" dir="auto">el título de la ventana</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id191587914134221" class="listitem" dir="auto">para documentos nuevos, algo como «Sin título 1»</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id911587914185746" class="listitem" dir="auto">una de las ventanas especiales «<span class="literal">BASICIDE</span>» y «<span class="literal">WELCOMESCREEN</span>»</p>
</li>
</ul>
<p id="par_id181587914255236" class="paragraph" dir="auto">El nombre de las ventanas distingue mayúsculas y minúsculas.</p>
<h3 id="hd_id541588520711430" dir="auto">Objeto Document</h3>
<p id="par_id841588521238711" class="paragraph" dir="auto">The methods <span class="literal">CreateDocument</span>, <span class="literal">CreateBaseDocument</span>, <span class="literal">GetDocument</span>, <span class="literal">OpenBaseDocument</span> and <span class="literal">OpenDocument</span>, described below, generate document objects. When a window contains a document, an instance of the <span class="literal">Document</span> class represents that document. A counterexample the Basic IDE is not a document but is a window in our terminology. Additionally a document has a type: <span class="literal">Calc</span>, <span class="literal">Impress</span>, <span class="literal">Writer</span>, ...</p>
<p id="par_id331588521254916" class="paragraph" dir="auto">The specific properties and methods applicable on documents are implemented in a document class.</p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id971588521292976" dir="auto">The implementation of the document objects class is done in the <span class="literal">SFDocuments</span> associated library. See its "<span class="literal">Document</span>" service.</p></div>
</div>
<br>
<h2 id="hd_id91587913266988" dir="auto">Invocación del servicio</h2>
<p id="par_id141609955500101" class="paragraph" dir="auto">Antes de utilizar el servicio <span class="literal">UI</span>, es necesario cargar o importar la biblioteca <span class="literal">ScriptForge</span>:</p>
<div class="embedded">
<a id="importLibs"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id901528999850603" dir="auto">• Para cargar la biblioteca <span class="literal">ScriptForge</span> que necesitan las macros de Basic se debe usar la siguiente declaración:<br><span class="literal">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</span><br><br>• Los scripts de Python necesitan importar el módulo <span class="literal">scriptforge</span>:<br><span class="literal">from scriptforge import CreateScriptService</span></p></div>
</div>
<br>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim ui As Variant
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
Set ui = CreateScriptService("UI")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
ui = CreateScriptService("UI")
</code></pre></div>
<h2 id="hd_id841587913266618" dir="auto">Propiedades</h2>
<a id="properties_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id521587913266568" class="tableheadintable" dir="auto">Nombre</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id421587913266368" class="tableheadintable" dir="auto">De solo lectura</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id631587914939732" class="tableheadintable" dir="auto">Tipo</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id951587913266220" class="tableheadintable" dir="auto">Descripción</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id161587913266162" class="tablecontentintable" dir="auto">ActiveWindow</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id651587913266754" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421587914989890" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id351587913266349" class="tablecontentintable" dir="auto">a valid and unique <span class="literal">WindowName</span> for the currently active window. When the window cannot be identified, a zero-length string is returned.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id161587913266563" class="tablecontentintable" dir="auto">Height</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id651587913266945" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421587914989732" class="tablecontentintable" dir="auto">Integer</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id351587913266211" class="tablecontentintable" dir="auto">Devuelve la altura en píxeles de la ventana activa.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id161587913266574" class="tablecontentintable" dir="auto">Width</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id651587913266645" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421587914989935" class="tablecontentintable" dir="auto">Integer</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id351587913266036" class="tablecontentintable" dir="auto">Devuelve la anchura de la ventana activa en píxeles.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id161587913266096" class="tablecontentintable" dir="auto">X</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id651587913266312" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421587914989789" class="tablecontentintable" dir="auto">Integer</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id351587913266296" class="tablecontentintable" dir="auto">Returns the X coordinate of the active window, which is the distance to the left edge of the screen in pixels.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id161587913266323" class="tablecontentintable" dir="auto">Y</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id651587913266670" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421587914989902" class="tablecontentintable" dir="auto">Integer</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id351587913266216" class="tablecontentintable" dir="auto">Returns the Y coordinate of the active window, which is the distance to the top edge of the screen in pixels. This value does not consider window decorations added by your operating system, so even when the window is maximized this value may not be zero.</p>
</td>
</tr>
</table>
<br>
<h2 id="hd_id511620762163390" dir="auto">Constantes</h2>
<a id="constants_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id761620761856238" class="tableheadintable" dir="auto">Nombre</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id591620761856238" class="tableheadintable" dir="auto">Valor</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id711620761856238" class="tableheadintable" dir="auto">Descripción</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id511620761856238" class="tablecontentintable" dir="auto">MACROEXECALWAYS</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id761620761856107" class="tablecontentintable" dir="auto">2</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id341620761856238" class="tablecontentintable" dir="auto">Las macros se ejecutan siempre</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id661620761881513" class="tablecontentintable" dir="auto">MACROEXECNEVER</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id661620761891082" class="tablecontentintable" dir="auto">1</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id101620761893011" class="tablecontentintable" dir="auto">Las macros no se ejecutan nunca</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id311620761888379" class="tablecontentintable" dir="auto">MACROEXECNORMAL</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id951620761899067" class="tablecontentintable" dir="auto">0</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id11620761899780" class="tablecontentintable" dir="auto">La ejecución de macros depende de la configuración del usuario</p>
</td>
</tr>
</table>
<br>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id311620312548992" class="paragraph" dir="auto">The examples below show a <span class="literal">MsgBox</span> with the names of all currently open documents.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim openDocs As Object, strDocs As String
Set openDocs = ui.Documents()
strDocs = openDocs(0)
For i = 1 To UBound(openDocs)
strDocs = strDocs & Chr(10) & openDocs(i)
Next i
MsgBox strDocs
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui = CreateScriptService("UI")
bas = CreateScriptService("Basic")
openDocs = ui.Documents()
strDocs = "\n".join(openDocs)
bas.MsgBox(strDocs)
</code></pre></div>
<a id="methods_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="3" class="tableheadcell" dir="auto">
<p id="par_id881608131596153" class="tableheadintable" dir="auto">Lista de métodos en el servicio UI</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto"><p id="par_id381606472825856" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#Activate">Activate</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#CreateBaseDocument">CreateBaseDocument</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#CreateDocument">CreateDocument</a> (*)<br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#Documents">Documents</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#GetDocument">GetDocument</a>
</p></td>
<td rowspan="" colspan="" dir="auto"><p id="par_id451606472825856" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#Maximize">Maximize</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#Minimize">Minimize</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#OpenBaseDocument">OpenBaseDocument</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#OpenDocument">OpenDocument</a> (*)<br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#Resize">Resize</a><br>
</p></td>
<td rowspan="" colspan="" dir="auto"><p id="par_id161606472825856" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#RunCommand">RunCommand</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#SetStatusBar">SetStatusBar</a> (*)<br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#ShowProgressBar">ShowProgressBar</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#WindowExists">WindowExists</a><br><br>
</p></td>
</tr>
</table>
<br>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id431620322170443" dir="auto">Note, as an exception, that the methods marked <span class="emph">(*)</span> are <span class="emph">not applicable to Base documents</span>.</p></div>
</div>
<br>
<a id="Activate"></a>
<a id="bm_id991587913266189"></a>
<meta itemprop="keywords" content="UI service,Activate">
<h2 id="hd_id76158791326673" dir="auto">Activate</h2>
<p id="par_id201587913266596" class="paragraph" dir="auto">Make the specified window active. The method returns <span class="literal">True</span> if the given window is found and can be activated. There is no change in the actual user interface if no window matches the selection.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id331620319796672" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Activate(windowname: str): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id381587913266946" class="paragraph" dir="auto"><span class="emph">windowname</span>: vea las definiciones más arriba.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
ui.Activate("C:\Documents\My file.odt")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.Activate(r"C:\Documents\My file.odt")
</code></pre></div>
<a id="CreateBaseDocument"></a>
<a id="bm_id871596554849122"></a>
<meta itemprop="keywords" content="UI service,CreateBaseDocument">
<h2 id="hd_id281596554849363" dir="auto">CreateBaseDocument</h2>
<p id="par_id13159655484952" class="paragraph" dir="auto">Crea y almacena un documento nuevo de LibreOffice Base que incrusta una base de datos vacía del tipo indicado. El método devuelve una instancia del servicio <span class="literal">Document</span>.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id461620320014911" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.CreateBaseDocument(filename: str, embeddeddatabase: str = 'HSQLDB', registrationname: str = '', opt calcfilename: str): svc</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id441596554849949" class="paragraph" dir="auto"><span class="emph">filename</span> : Identifies the file to create. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation. If the file already exists, it is overwritten without warning.</p>
<p id="par_id381596554849698" class="paragraph" dir="auto"><span class="emph">embeddeddatabase</span>: puede ser «HSQLDB» (valor predeterminado), «FIREBIRD» o «CALC».</p>
<p id="par_id521596554849185" class="paragraph" dir="auto"><span class="emph">registrationname</span> : The name used to store the new database in the databases register. When = "" (default), no registration takes place. If the name already exists it is overwritten without warning.</p>
<p id="par_id181629364905056" class="paragraph" dir="auto"><span class="emph">calcfilename</span> : Only when <span class="literal">embeddeddatabase</span> = "CALC", <span class="literal">calcfilename</span> represents the file containing the tables as Calc sheets. The file must exist or an error is raised.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myBase As Object, myCalcBase As Object
Set myBase = ui.CreateBaseDocument("C:\Databases\MyBaseFile.odb", "FIREBIRD")
Set myCalcBase = ui.CreateBaseDocument("C:\Databases\MyCalcBaseFile.odb", _
"CALC", , "C:\Databases\MyCalcFile.ods")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
myBase = ui.CreateBaseDocument(r"C:\Databases\MyBaseFile.odb", "FIREBIRD")
myCalcBase = ui.CreateBaseDocument(r"C:\Databases\MyCalcBaseFile.odb", \
"CALC", calcfilename = r"C:\Databases\MyCalcFile.ods")
</code></pre></div>
<a id="CreateDocument"></a>
<a id="bm_id461588521753429"></a>
<meta itemprop="keywords" content="UI service,CreateDocument">
<h2 id="hd_id45158852175376" dir="auto">CreateDocument (*)</h2>
<p id="par_id651588521753997" class="paragraph" dir="auto">Create a new LibreOffice document of a given type or based on a given template. The method returns an instance of the document class or one of its subclasses (Calc, Writer).</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id401620320696126" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.CreateDocument(documenttype: str = '', templatefile: str = '', hidden: bool = False): svc</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id51588521753302" class="paragraph" dir="auto"><span class="emph">documenttype</span>: «Calc», «Writer», etc. Si está ausente, debe existir el argumento <span class="literal">templatefile</span>.</p>
<p id="par_id401588522663325" class="paragraph" dir="auto"><span class="emph">templatefile</span> : The full <span class="literal">FileName</span> of the template to build the new document on. If the file does not exist, the argument is ignored. The <span class="literal">FileSystem</span> service provides the <span class="literal">TemplatesFolder</span> and <span class="literal">UserTemplatesFolder</span> properties to help to build the argument.</p>
<p id="par_id131588522824366" class="paragraph" dir="auto"><span class="emph">hidden</span>: if <span class="literal">True</span>, open the new document in the background (default = <span class="literal">False</span>). To use with caution: activation or closure afterwards can only happen programmatically.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id701620762417802" class="paragraph" dir="auto">In both examples below, the first call to <span class="literal">CreateDocument</span> method creates a blank Calc document, whereas the second creates a document from a template file.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myDoc1 As Object, myDoc2 As Object, FSO As Object
Set myDoc1 = ui.CreateDocument("Calc")
Set FSO = CreateScriptService("FileSystem")
Set myDoc2 = ui.CreateDocument(, FSO.BuildPath(FSO.TemplatesFolder, "personal/CV.ott"))
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
myDoc1 = ui.CreateDocument("Calc")
fs = CreateScriptService("FileSystem")
myDoc2 = ui.CreateDocument(templatefile = fs.BuildPath(fs.TemplatesFolder, "personal/CV.ott"))
</code></pre></div>
<a id="Documents"></a>
<a id="bm_id461589631753429"></a>
<meta itemprop="keywords" content="UI service,Documents">
<h2 id="hd_id45159962175376" dir="auto">Documents</h2>
<p id="par_id651699521753997" class="paragraph" dir="auto">The list of the currently open documents. Special windows are ignored. This list consists of a zero-based one dimensional array either of filenames - using <a target="_top" href="es/text/sbasic/shared/03/sf_filesystem.html#properties_toc">ScriptForge.FileSystem.FileNaming</a> notation - or of window titles for unsaved documents.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id401732430696126" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Documents(): str[1..*]</span>
</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id701620773517802" class="paragraph" dir="auto">In both examples below, the method may return an empty array if there are no documents open.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim docList As Variant
docList = ui.Documents
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
docList = ui.Documents()
</code></pre></div>
<a id="GetDocument"></a>
<a id="bm_id351588520551838"></a>
<meta itemprop="keywords" content="UI service,GetDocument">
<h2 id="hd_id171588520551515" dir="auto">GetDocument</h2>
<p id="par_id201588520551463" class="paragraph" dir="auto">Returns an instance of the Document class or one of its subclasses (Calc, Writer, Base, FormDocument) referring to either a given window or the active document.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id811620320778478" class="paragraph" dir="auto"> <span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.GetDocument(windowname: str = ''): svc</span></p>
<p id="par_id251624026292796" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.GetDocument(windowname: uno): svc</span></p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id851588520551368" class="paragraph" dir="auto"><span class="emph">windowname</span>: See the definitions <a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#WindowName">above</a>. If this argument is absent, the active window is used. UNO objects of types <span class="literal">com.sun.star.lang.XComponent</span> or <span class="literal">com.sun.star.comp.dba.ODatabaseDocument</span> are also accepted. Thus passing <span class="literal">ThisComponent</span> or <span class="literal">ThisDatabaseDocument</span> as argument creates a new <a target="_top" href="es/text/sbasic/shared/03/sf_document.html">SFDocuments.Document</a>, <a target="_top" href="es/text/sbasic/shared/03/sf_base.html">Base</a> or <a target="_top" href="es/text/sbasic/shared/03/sf_calc.html">Calc</a> service.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myDoc As Object
Set myDoc = ui.GetDocument("C:\Documents\My file.odt")
Set myBase = ui.GetDocument(ThisDatabaseDocument)
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
bas = CreateScriptService("Basic")
myDoc = ui.GetDocument(r"C:\Documents\My file.odt")
myDoc = ui.GetDocument(bas.ThisComponent)
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id521620330287071" dir="auto">Para acceder al nombre de la ventana actualmente activa, vea la propiedad <span class="literal">ActiveWindow</span>.</p></div>
</div>
<br>
<a id="Maximize"></a>
<a id="bm_id441587986441397"></a>
<meta itemprop="keywords" content="UI service,Maximize">
<h2 id="hd_id261587986441738" dir="auto">Maximize</h2>
<p id="par_id24158798644169" class="paragraph" dir="auto">Maximiza la ventana activa o la ventana dada.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id631620320925633" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Maximize(windowname: str)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id951587986441954" class="paragraph" dir="auto"><span class="emph">windowname</span>: see the definitions <a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#WindowName">above</a>. If this argument is absent, the active window is maximized.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
ui.Maximize("Untitled 1")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.Maximize("Untitled 1")
</code></pre></div>
<a id="Minimize"></a>
<a id="bm_id2315879865929"></a>
<meta itemprop="keywords" content="UI service,Minimize">
<h2 id="hd_id21158798659210" dir="auto">Minimize</h2>
<p id="par_id871587986592696" class="paragraph" dir="auto">Minimiza la ventana activa o la ventana indicada.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id201620321224368" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Minimize(windowname: str)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id751587986592626" class="paragraph" dir="auto"><span class="emph">windowname</span>: see the definitions <a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#WindowName">above</a>. If this argument is absent, the active window is minimized.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
ui.Minimize()
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.Minimize()
</code></pre></div>
<a id="OpenBaseDocument"></a>
<a id="bm_id291596555746452"></a>
<meta itemprop="keywords" content="UI service,OpenBaseDocument">
<h2 id="hd_id671596555746148" dir="auto">OpenBaseDocument</h2>
<p id="par_id691596555746539" class="paragraph" dir="auto">Open an existing LibreOffice Base document. The method returns a <span class="literal">Base</span> object.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id21620321395150" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.OpenBaseDocument(filename: str = '', registrationname: str = '', macroexecution: int = 0): svc</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id231596555746385" class="paragraph" dir="auto"><span class="emph">filename</span>: Identifies the file to open. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
<p id="par_id711596555746281" class="paragraph" dir="auto"><span class="emph">registrationname</span>: The name to use to find the database in the databases register. It is ignored if <span class="literal">FileName</span> <> "".</p>
<p id="id721596556313545" class="paragraph" dir="auto"><span class="emph">macroexecution</span>: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable. Default is 0.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myBase As Object
Set myBase = ui.OpenBaseDocument("C:\Documents\myDB.odb", MacroExecution := ui.MACROEXECALWAYS)
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
myBase = ui.OpenBaseDocument(r"C:\Documents\myDB.odb", macroexecution = ui.MACROEXECALWAYS)
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id941620762989833" dir="auto">To improve code readability you can use <a target="_top" href="es/text/sbasic/shared/03/sf_ui.html#constants_toc">predefined constants</a> for the <span class="literal">macroexecution</span> argument, as in the examples above.</p></div>
</div>
<br>
<a id="OpenDocument"></a>
<a id="bm_id141588523635836"></a>
<meta itemprop="keywords" content="UI service,OpenDocument">
<h2 id="hd_id451588523635719" dir="auto">OpenDocument (*)</h2>
<p id="par_id541588523635283" class="paragraph" dir="auto">Opens an existing LibreOffice document with the given options. Returns a document object or one of its subclasses. The method returns <span class="literal">Nothing</span> (in BASIC) or <span class="literal">None</span> (in Python) if the opening failed, even when the failure is caused by a user decision.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id271620321692960" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Opendocument(filename: str, password: str = '', readonly: bool = False, hidden: bool = False, macroexecution: int = 0, filtername: str = '', filteroptions: str = ''): svc</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id481588523635890" class="paragraph" dir="auto"><span class="emph">filename</span>: identifica el archivo que se debe abrir. Debe seguir la notación de <span class="literal">FileNaming</span> del servicio <span class="literal">FileSystem</span>.</p>
<p id="par_id451588523635507" class="paragraph" dir="auto"><span class="emph">password</span>: To use when the document is protected. If wrong or absent while the document is protected, the user will be prompted to enter a password.</p>
<p id="par_id611588524329781" class="paragraph" dir="auto"><span class="emph">readonly</span>: el valor predeterminado es <span class="literal">False</span>.</p>
<p id="par_id641588523635497" class="paragraph" dir="auto"><span class="emph">hidden</span>: if <span class="literal">True</span>, open the new document in the background (default = <span class="literal">False</span>). To use with caution: activation or closure afterwards can only happen programmatically.</p>
<p id="par_id981588524474719" class="paragraph" dir="auto"><span class="emph">macroexecution</span>: 0 = behaviour is defined by the user configuration, 1 = macros are not executable, 2 = macros are executable. Default is 0.</p>
<p id="par_id611588524584693" class="paragraph" dir="auto"><span class="emph">filtername</span>: el nombre del filtro que debe utilizarse para cargar el documento. Si está presente, el filtro debe existir.</p>
<p id="par_id191588524634348" class="paragraph" dir="auto"><span class="emph">filteroptions</span>: una cadena facultativa de opciones relacionadas al filtro.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim myDoc As Object, FSO As Object
Set myDoc = ui.OpenDocument("C:\Documents\myFile.odt", ReadOnly := True)
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
myDoc = ui.OpenDocument(r"C:\Documents\myFile.odt", readonly = True)
</code></pre></div>
<a id="Resize"></a>
<a id="bm_id951587986945259"></a>
<meta itemprop="keywords" content="UI service,Resize">
<h2 id="hd_id551587986945514" dir="auto">Resize</h2>
<p id="par_id751587986945965" class="paragraph" dir="auto">Resizes and/or moves the active window. Absent and negative arguments are ignored. If the window is minimized or maximized, calling <span class="literal">Resize</span> without arguments restores it.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id411620321819387" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Resize(left: int = -1, top: int = -1, width: int = -1, height: int = -1)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id441587986945696" class="paragraph" dir="auto"><span class="emph">left, top</span>: Distances of the top-left corner from top and left edges of the screen, in pixels.</p>
<p id="par_id601587987453825" class="paragraph" dir="auto"><span class="emph">width, height</span>: dimensiones nuevas para la ventana, en píxeles.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id801587987507028" class="paragraph" dir="auto">In the following examples, the <span class="literal">width</span> and <span class="literal">height</span> of the window are changed while <span class="literal">top</span> and <span class="literal">left</span> are left unchanged.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
ui.Resize(Width := 500, Height := 500)
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.Resize(width = 500, height = 500)
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id21620332301809" dir="auto">To resize a window that is not active, first activate it using the <span class="literal">Activate</span> method.</p></div>
</div>
<br>
<a id="RunCommand"></a>
<a id="bm_id601589202413561"></a>
<meta itemprop="keywords" content="UI service,RunCommand">
<h2 id="hd_id611589202413141" dir="auto">RunCommand</h2>
<p id="par_id991589202413257" class="paragraph" dir="auto">Runs a UNO command on the current window. A few typical commands are: Save, SaveAs, ExportToPDF, Undo, Copy, Paste, etc.</p>
<p id="par_id921611152932311" class="paragraph" dir="auto">Commands can be run with or without arguments. Arguments are not validated before running the command. If the command or its arguments are invalid, then nothing will happen.</p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31644182402479" dir="auto">For a complete list of UNO commands that can be run in LibreOffice, refer to the Wiki page <a target="_blank" href="https://wiki.documentfoundation.org/Development/DispatchCommands">Development/DispatchCommands</a>.</p></div>
</div>
<br>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id521622828226683" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.RunCommand(command: str, [args: any])</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id401589202413575" class="paragraph" dir="auto"><span class="emph">command</span>: Case-sensitive string containing the UNO command name. The inclusion of the prefix ".uno:" in the command is optional. The command itself is not checked for correctness. If nothing happens after the command call, then the command is probably wrong.</p>
<p id="par_id521644182774710" class="paragraph" dir="auto"><span class="emph">args</span>: For each argument to be passed to the command, specify a pair containing the argument name and value.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<p id="par_id721611153068137" class="paragraph" dir="auto">El ejemplo siguiente ejecuta la orden <span class="literal">.uno:About</span> en la ventana actual.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Set ui = CreateScriptService("UI")
ui.RunCommand("About")
</code></pre></div>
<p id="par_id371644184276886" class="paragraph" dir="auto">Below is an example that runs the UNO command <span class="literal">.uno:BasicIDEAppear</span> and passes the arguments required to open the Basic IDE at a specific line of a module.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
' Argumentos pasados a la orden:
' Document = "LibreOffice Macros & Dialogs"
' LibName = "ScriptForge"
' Name = "SF_Session"
' Line = 600
ui.RunCommand(".uno:BasicIDEAppear", "Document", "LibreOffice Macros & Dialogs", _
"LibName", "ScriptForge", "Name", "SF_Session", "Line", 600)
</code></pre></div>
<p id="par_id41644184549167" class="paragraph" dir="auto">Observe que si invoca la orden <span class="literal">BasicIDEAppear</span> sin argumentos simplemente se abrirá el <span class="menuitem">EDI de BASIC</span>.</p>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui = CreateScriptService("UI")
ui.RunCommand("About")
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.RunCommand(".uno:BasicIDEAppear", "Document", "LibreOffice Macros & Dialogs", \
"LibName", "ScriptForge", "Name", "SF_Session", "Line", 600)
</code></pre></div>
<p id="par_id311644243516674" class="paragraph" dir="auto">In Python it is also possible to call <span class="literal">RunCommand</span> using keyword arguments:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
ui.RunCommand(".uno:BasicIDEAppear", Document = "LibreOffice Macros & Dialogs", \
LibName = "ScriptForge", Name = "SF_Session", Line = 600)
</code></pre></div>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id191611153511038" dir="auto">Each LibreOffice component has its own set of commands available. One easy way to learn commands is going to <span class="emph">Tools - Customize - Keyboard</span>. When you position your mouse over a function in the <span class="emph">Function</span> list, a tooltip will appear with the corresponding UNO command.</p></div>
</div>
<br>
<a id="SetStatusBar"></a>
<a id="bm_id25158799642119"></a>
<meta itemprop="keywords" content="UI service,SetStatusbar">
<h2 id="hd_id171587996421550" dir="auto">SetStatusbar (*)</h2>
<p id="par_id281587996421580" class="paragraph" dir="auto">Display a text and a progressbar in the status bar of the active window. Any subsequent calls in the same macro run refer to the same status bar of the same window, even if the window is not visible anymore. A call without arguments resets the status bar to its normal state.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id461620321923929" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.SetStatusbar(text: str = '', percentage: int = -1)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id71587996421829" class="paragraph" dir="auto"><span class="emph">text</span>: An optional text to be displayed in front of the progress bar.</p>
<p id="par_id881587996421777" class="paragraph" dir="auto"><span class="emph">percentage</span>: an optional degree of progress between 0 and 100.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim i As Integer
For i = 0 To 100
ui.SetStatusbar("Progress ...", i)
Wait 50
Next i
' Restablece la barra de estado
ui.SetStatusbar
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from time import sleep
for i in range(101):
ui.SetStatusbar("Test:", i)
sleep(0.05)
ui.SetStatusbar()
</code></pre></div>
<a id="ShowProgressBar"></a>
<a id="bm_id91159886425573"></a>
<meta itemprop="keywords" content="UI service,ShowProgressBar">
<h2 id="hd_id31598864255380" dir="auto">ShowProgressBar</h2>
<p id="par_id571598864255776" class="paragraph" dir="auto">Displays a non-modal dialog box. Specify its title, an explicatory text and a percentage of progress to be represented on a progressbar. The dialog will remain visible until a call to the method without arguments or until the user manually closes the dialog.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id41620322016943" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.ShowProgressBar(title: str = '', text: str = '', percentage: int = -1)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id441598864535695" class="paragraph" dir="auto"><span class="emph">title</span> : The title appearing on top of the dialog box. Default = "ScriptForge".</p>
<p id="par_id311598864255297" class="paragraph" dir="auto"><span class="emph">text</span>: An optional text to be displayed above the progress bar.</p>
<p id="par_id881598864255424" class="paragraph" dir="auto"><span class="emph">percentage</span>: an optional degree of progress between 0 and 100.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim i As Integer
For i = 0 To 100
ui.ShowProgressBar("Window Title", "Progress ..." & i & "/100", i)
Wait 50
Next i
' Cierra la ventana de la barra de progreso
ui.ShowProgressBar
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from time import sleep
for i in range(101):
ui.ShowProgressBar("Window Title", "Progress ... " + str(i) + "/100", i)
sleep(0.05)
# Cierra la ventana de la barra de progreso
ui.ShowProgressBar()
</code></pre></div>
<a id="WindowExists"></a>
<a id="bm_id431588587119136"></a>
<meta itemprop="keywords" content="UI service,WindowExists">
<h2 id="hd_id21588587119344" dir="auto">WindowExists</h2>
<p id="par_id431588587119925" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the given window could be identified.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id521620322090015" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.WindowExists(windowname: str): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id45158858711917" class="paragraph" dir="auto"><span class="emph">windowname</span>: vea las definiciones más arriba.</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
If ui.WindowExists("C:\Document\My file.odt") Then
' ...
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
if ui.WindowExists(r"C:\Document\My file.odt"):
# ...
</code></pre></div>
<a id="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a id="related"></a><span class="emph">Temas relacionados</span></p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_basic.html">Servicio <span class="literal">ScriptForge</span>.<span class="literal">Basic</span></a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_calc.html"><span class="literal">SFDocuments</span>.<span class="literal">Calc</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_document.html">Servicio <span class="literal">SFDocuments</span>.<span class="literal">Document</span></a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><h2 style="text-align: center;"><a href="https://books.libreoffice.org" target="_blank">Libros de LibreOffice</a></h2>
<div class="noteicon" dir="auto" style="display:flex;justify-content:center;flex-wrap:wrap;row-gap:15px;">
<img src="media/navigation/libo-writer.svg" alt="Writer Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-calc.svg" alt="Calc Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-impress.svg" alt="Impress Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-draw.svg" alt="Draw Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-base.svg" alt="Base Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-math.svg" alt="Math Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-symbol-black.svg" alt="Getting Started Icon" style="width:60px;height:60px;">
</div>
<div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_ui.xhp" target="_blank">/text/sbasic/shared/03/sf_ui.xhp</a></p>
<p dir="auto">Title is: Servicio ScriptForge.UI</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>