<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Servicio SFDocuments.Document</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="SFDocuments-sf_document"></a>
<a id="bm_id261582733781987"></a>
<meta itemprop="keywords" content="Document service">
<a id="abstract"></a>
<h1 id="hd_id731582733781114" dir="auto">
<a id="DocumentService"></a>Servicio <span class="literal">SFDocuments</span>.<span class="literal">Document</span>
</h1>
<p id="par_id381589189355849" class="paragraph" dir="auto">The <span class="literal">SFDocuments</span> library provides methods and properties to facilitate the management and manipulation of LibreOffice documents.</p>
<p id="par_id591589189364267" class="paragraph" dir="auto">Methods that are applicable for all types of documents (Text Documents, Sheets, Presentations, etc) are provided by the <span class="literal">SFDocuments.Document</span> service. Some examples are:</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_id891589189452545" class="listitem" dir="auto">Abrir, cerrar y guardar documentos</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id811589189463041" class="listitem" dir="auto">Acceder a propiedades estándares o personalizadas de los documentos</p>
</li>
</ul>
<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_id301611085807704" dir="auto">Las propiedades, los métodos y los argumentos que se señalan con un <span class="emph">(*)</span> <span class="emph">NO son aplicables a los documentos de Base</span>.</p></div>
</div>
<br>
<p id="par_id241589189701274" class="paragraph" dir="auto">Methods and properties that are specific to certain LibreOffice components are stored in separate services, such as <span class="literal">SFDocuments.SF_Calc</span> and <span class="literal">SFDocuments.SF_Base</span>.</p>
<p id="par_id641611090052376" class="paragraph" dir="auto">Although the Basic language does not offer inheritance between object classes, the latter services may be considered as subclasses of the <span class="literal">SFDocuments.Document</span> service. Such subclasses can invoke the properties and methods described below.</p>
<h2 id="hd_id581582885621841" dir="auto">Invocación del servicio</h2>
<p id="par_id141609955500101" class="paragraph" dir="auto">Antes de utilizar el servicio <span class="literal">Document</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>
<p id="par_id581611090387382" class="paragraph" dir="auto">Below are three variants of how the <span class="literal">Document</span> service can be invoked.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<p id="par_id181622816732197" class="paragraph" dir="auto">Using the <span class="literal">getDocument</span> method from the <span class="literal">ScriptForge</span>.<span class="literal">UI</span> service:</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">
Dim ui As Object, oDoc As Object
Set ui = CreateScriptService("UI")
Set oDoc = ui.GetDocument("Untitled 1")
</code></pre></div>
<p id="par_id181622818236233" class="paragraph" dir="auto">Alternatively you can use the methods <span class="literal">CreateDocument</span> and <span class="literal">OpenDocument</span> from the <span class="literal">UI</span> service.</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 oDocA = ui.CreateDocument("Calc")
Set oDocB = ui.OpenDocument("C:\Documents\MyFile.odt")
</code></pre></div>
<p id="par_id691622816765571" class="paragraph" dir="auto">Using a window name if the document is already open.</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">
Dim oDoc As Object
Set oDoc = CreateScriptService("SFDocuments.Document", "Untitled 1") 'Default = ActiveWindow
</code></pre></div>
<p id="par_id551658777771853" class="paragraph" dir="auto">Using the document referenced by <span class="literal">ThisComponent</span>. This is specially useful when running a macro from within the Basic IDE.</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">
Dim oDoc As Object
Set oDoc = CreateScriptService("Document", ThisComponent)
</code></pre></div>
<p id="par_id821622816825012" class="paragraph" dir="auto">A partir de una macro desencadenada por un evento del documento.</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">
Sub RunEvent(ByRef poEvent As Object)
Dim oDoc As Object
Set oDoc = CreateScriptService("SFDocuments.DocumentEvent", poEvent)
' (...)
End Sub
</code></pre></div>
<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_id831622816562430" dir="auto">The <span class="literal">Document</span> service is closely related to the <span class="literal">UI</span> and <span class="literal">FileSystem</span> services.</p></div>
</div>
<br>
<p id="par_id891582733781994" class="paragraph" dir="auto">Except when the document was closed by program with the CloseDocument method (it is then superfluous), it is recommended to free resources after use:</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 oDoc = oDoc.Dispose()
</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")
doc = ui.GetDocument("Untitled 1")
# (...)
doc.Dispose()
</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">
docA = ui.CreateDocument("Calc")
docB = ui.OpenDocument("C:\Documents\MyFile.odt")
</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">
doc = CreateScriptService("SFDocuments.Document", "Untitled 1")
</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">
bas = CreateScriptService("Basic")
doc = CreateScriptService("Document", bas.ThisComponent)
</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">
def RunEvent(event)
doc = CreateScriptService("SFDocuments.DocumentEvent", Event)
# (...)
</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_id71611090922315" dir="auto">El uso del prefijo «<span class="literal">SFDocuments.</span>» al llamar el servicio es facultativo.</p></div>
</div>
<br>
<a id="bm_id81611339709014"></a>
<meta itemprop="keywords" content="API,Duration">
<meta itemprop="keywords" content="API,XComponent">
<meta itemprop="keywords" content="API,ODatabaseDocument">
<meta itemprop="keywords" content="Document service,CustomProperties property">
<meta itemprop="keywords" content="Document service,Description property">
<meta itemprop="keywords" content="Document service,DocumentProperties property">
<meta itemprop="keywords" content="Document service,DocumentType property">
<meta itemprop="keywords" content="Document service,ExportFilters property">
<meta itemprop="keywords" content="Document service,FileSystem property">
<meta itemprop="keywords" content="Document service,ImportFilters property">
<meta itemprop="keywords" content="Document service,IsBase property">
<meta itemprop="keywords" content="Document service,IsCalc property">
<meta itemprop="keywords" content="Document service,IsDraw property">
<meta itemprop="keywords" content="Document service,IsFormDocument property">
<meta itemprop="keywords" content="Document service,IsImpress property">
<meta itemprop="keywords" content="Document service,IsMath property">
<meta itemprop="keywords" content="Document service,IsWriter property">
<meta itemprop="keywords" content="Document service,Keywords property">
<meta itemprop="keywords" content="Document service,Readonly property">
<meta itemprop="keywords" content="Document service,StyleFamilies property">
<meta itemprop="keywords" content="Document service,Subject property">
<meta itemprop="keywords" content="Document service,Title property">
<meta itemprop="keywords" content="Document service,XComponent property">
<meta itemprop="keywords" content="Document service,XDocumentSettings property">
<h2 id="hd_id351582885195476" 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_id41582885195836" class="tableheadintable" dir="auto">Nombre</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id31582885195372" class="tableheadintable" dir="auto">De solo lectura</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id31582885195238" class="tableheadintable" dir="auto">Tipo</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id931582885195131" class="tableheadintable" dir="auto">Descripción</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id7715828856553" class="tablecontentintable" dir="auto">CustomProperties (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id861582885655779" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id271582885655525" class="tablecontentintable" dir="auto">Dictionary service</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id581582885655885" class="tablecontentintable" dir="auto">Returns a <span class="literal">ScriptForge.Dictionary</span> object instance. After update, can be passed again to the property for updating the document.<br>Individual items of the dictionary may be either strings, numbers, (Basic) dates or <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/structcom_1_1sun_1_1star_1_1util_1_1Duration.html"><span class="literal">com.sun.star.util.Duration</span></a> items.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id841582886030384" class="tablecontentintable" dir="auto">Description (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id441582886030118" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id131582886030297" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id471582886030489" class="tablecontentintable" dir="auto">Da acceso a la propiedad Description del documento (conocida también como «Comments»)</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id231582886791351" class="tablecontentintable" dir="auto">DocumentProperties (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id971582886791838" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id271582886791111" class="tablecontentintable" dir="auto">Dictionary service</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id16158288679167" class="tablecontentintable" dir="auto">Devuelve un objeto <span class="literal">ScriptForge.Dictionary</span> que contiene todas las entradas. Las estadísticas del documento también se incluyen. Observe que los elementos del diccionario dependen del tipo de documento. Por ejemplo, un documento de Calc incluye una entrada «CellCount», mientras que otros tipos de documento no tienen esa entrada.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881589194571813" class="tablecontentintable" dir="auto">DocumentType</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589194571955" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id951589194571781" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941589194571801" class="tablecontentintable" dir="auto">Valor de cadena con el tipo de documento («Base», «Calc», «Writer», etc.)</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881589194572136" class="tablecontentintable" dir="auto">ExportFilters (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589194571699" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id951589194571391" class="tablecontentintable" dir="auto">String array</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941589194571327" class="tablecontentintable" dir="auto">Returns a list with the export filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881589194574646" class="tablecontentintable" dir="auto">FileSystem</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589194571306" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id951589194571114" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941589194571044" class="tablecontentintable" dir="auto">Returns a string with the URL path to the root of the virtual file system of the document. Use the <span class="literal">FileSystem</span> service to view its contents, as well as to create, open and read files stored in it.</p>
<p id="par_id941589194576584" class="tablecontentintable" dir="auto">Refer to <a target="_top" href="es/text/sbasic/shared/03/sf_filesystem.html#virtual_fs">this help page</a> to learn more on how to access and manipulate folders and files in the virtual file system of a LibreOffice file.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881589194573253" class="tablecontentintable" dir="auto">ImportFilters (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589194571067" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id951589194571292" class="tablecontentintable" dir="auto">String array</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941589194571922" class="tablecontentintable" dir="auto">Returns a list with the import filter names applicable to the current document as a zero-based array of strings. Filters used for both import/export are also returned.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id241589194633142" class="tablecontentintable" dir="auto">
IsBase<br>IsCalc<br>IsDraw<br>IsFormDocument<br>IsImpress<br>IsMath<br>IsWriter
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id761589194633950" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id741589194633956" class="tablecontentintable" dir="auto">Boolean</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id611589194633853" class="tablecontentintable" dir="auto">Exactly one of these properties is <span class="literal">True</span> for a given document.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id311589194910727" class="tablecontentintable" dir="auto">Keywords (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id231589194910179" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id421589194910942" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id311589194910190" class="tablecontentintable" dir="auto">Da acceso a la propiedad Keywords del documento. Se representa como una lista de palabras clave separadas por comas</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id911589638614922" class="tablecontentintable" dir="auto">Readonly (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id921589638614972" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id501589638614132" class="tablecontentintable" dir="auto">Boolean</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id801589638614518" class="tablecontentintable" dir="auto"><span class="literal">True</span> si el documento está en el modo de solo lectura</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id921589195028191" class="tablecontentintable" dir="auto">StyleFamilies (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589196128733" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id551589195138724" class="tablecontentintable" dir="auto">String array</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id372699195028843" class="tablecontentintable" dir="auto">List of available style families. Applicable to all document types except Base.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id031589195028191" class="tablecontentintable" dir="auto">Subject (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id201589195028733" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id551589195028724" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id371589195028843" class="tablecontentintable" dir="auto">Da acceso a la propiedad Subject del documento.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id521589195028736" class="tablecontentintable" dir="auto">Title (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id451589195028910" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id31589195028773" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id771589195028748" class="tablecontentintable" dir="auto">Da acceso a la propiedad Title del documento.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id97158288519551" class="tablecontentintable" dir="auto">XComponent</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id221582885195686" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id371582885195525" class="tablecontentintable" dir="auto">Objeto UNO</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881582885195976" class="tablecontentintable" dir="auto">The UNO object <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XComponent.html"><span class="literal">com.sun.star.lang.XComponent</span></a> or <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sdb_1_1OfficeDatabaseDocument.html"><span class="literal">com.sun.star.comp.dba.ODatabaseDocument</span></a> representing the document.</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id97158299619551" class="tablecontentintable" dir="auto">XDocumentSettings (*)</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id232682885195686" class="tablecontentintable" dir="auto">Sí</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id371693885195525" class="tablecontentintable" dir="auto">Objeto UNO</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id881582885205976" class="tablecontentintable" dir="auto">A <span class="literal">com.sun.star.XXX.DocumentSettings</span> UNO object, where XXX is either <span class="literal">sheet</span>, <span class="literal">text</span>, <span class="literal">drawing</span> or <span class="literal">presentation</span>. This object gives access to the internal UNO properties that are specific to the document's type.</p>
</td>
</tr>
</table>
<br>
<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_id861611146581334" class="paragraph" dir="auto">The example below prints all the properties of a document. Note that the <span class="literal">oDoc</span> object returned by the <span class="literal">UI.OpenDocument</span> method is a <span class="literal">SFDocuments.Document</span> object.</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">
Dim ui as Variant : Set ui = CreateScriptService("UI")
Dim oDoc as Object
Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods")
Dim propDict as Object
Set propDict = oDoc.DocumentProperties
Dim keys as Variant : propKeys = propDict.Keys
Dim k as String, strProp as String
For Each k In propKeys
strProp = strProp & k & ": " & propDict.Item(k) & CHR$(10)
Next k
MsgBox strProp
oDoc.CloseDocument()
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<p id="par_id571622826920742" class="paragraph" dir="auto">To access document properties in a Python script the user needs to directly access them using their names, as shown below:</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">
doc = ui.GetDocument(r"C:\Documents\MyFile.ods")
msg = doc.Title + '\n' + doc.Description + '\n' + doc.Keywords
bas = CreateScriptService("Basic")
bas.MsgBox(msg)
doc.CloseDocument()
</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_id651606319520519" class="tableheadintable" dir="auto">Lista de métodos en el servicio Document</p></th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id761611086279902" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#Activate">Activate</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#CloseDocument">CloseDocument</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#CreateMenu">CreateMenu</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#DeleteStyles">DeleteStyles</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#Echo">Echo</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#ExportAsPDF">ExportAsPDF</a><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id141611086279902" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#PrintOut">PrintOut</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#RemoveMenu">RemoveMenu</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#RunCommand">RunCommand</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#Save">Save</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#SaveAs">SaveAs</a><br><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id761611086279903" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#SaveCopyAs">SaveCopyAs</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#SetPrinter">SetPrinter</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#Style">Style</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#Toolbars">Toolbars</a><br>
<a target="_top" href="es/text/sbasic/shared/03/sf_document.html#SetPrinter">XStyle</a><br><br>
</p>
</td>
</tr>
</table>
<br>
<a id="Activate"></a>
<a id="bm_id92158919969883"></a>
<meta itemprop="keywords" content="Document service,Activate">
<h2 id="hd_id201589199698251" dir="auto">Activate</h2>
<p id="par_id93158919969864" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the document could be activated. Otherwise, there is no change in the actual user interface. It is equivalent to the <span class="literal">Activate</span> method of the <span class="literal">UI</span> service.</p>
<p id="par_id421611148353046" class="paragraph" dir="auto">Este método es útil cuando se necesita dar el foco a un documento que está minimizado u oculto.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id181622827609276" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Activate(): bool</span>
</p>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<p id="par_id601611148017930" class="paragraph" dir="auto">The example below considers that the file "My_File.ods" is already open but not active.</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 oDoc As Object
Set oDoc = CreateScriptService("Document", "MyFile.ods")
oDoc.Activate()
</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">
doc = CreateScriptService("Document", "MyFile.ods")
doc.Activate()
</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_id601611148080503" dir="auto">Keep in mind that you can invoke the <span class="literal">Document</span> service by passing to <span class="literal">CreateScriptService</span> either "Document" or "SFDocuments.Document"</p></div>
</div>
<br>
<a id="CloseDocument"></a>
<a id="bm_id721589200121249"></a>
<meta itemprop="keywords" content="Document service,CloseDocument">
<h2 id="hd_id261589200121415" dir="auto">CloseDocument</h2>
<p id="par_id651589200121138" class="paragraph" dir="auto">Closes the document. If the document is already closed, regardless of how the document was closed, this method has no effect and returns <span class="literal">False</span>.</p>
<p id="par_id341611149562894" class="paragraph" dir="auto">The method will also return <span class="literal">False</span> if the user declines to close it.</p>
<p id="par_id981611149616934" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the document was successfully closed.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622887222169" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.CloseDocument(saveask: bool = True): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id361589200121646" class="paragraph" dir="auto"><span class="emph">saveask</span> : If <span class="literal">True</span> (default), the user is invited to confirm if the changes should be written on disk. This argument is ignored if the document was not modified.</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 oDoc.CloseDocument(True) Then
' ...
End If
</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 doc.CloseDocument(True):
# ...
</code></pre></div>
<a id="CreateMenu"></a>
<a id="bm_id721589200120958"></a>
<meta itemprop="keywords" content="Document service,CreateMenu">
<h2 id="hd_id261589200121339" dir="auto">CreateMenu</h2>
<p id="par_id651589200121080" class="paragraph" dir="auto">Creates a new menu entry in the menubar of a given document window.</p>
<p id="par_id981611149616155" class="paragraph" dir="auto">This method returns an instance of the <a target="_top" href="es/text/sbasic/shared/03/sf_menu.html"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">SFWidgets.Menu</span></a> service.</p>
<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_id721643121487974" dir="auto">The menu created is only available during the current LibreOffice session and is not saved neither in the document nor in the global application settings. Hence closing the document window will make the menu disappear. It will only reappear when the macro that creates the menu is executed again.</p></div>
</div>
<br>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622887222964" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.CreateMenu(menuheader: str, [before: any], submenuchar: str = ">"): svc</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id361589200120316" class="paragraph" dir="auto"><span class="emph">menuheader</span>: The toplevel name of the new menu.</p>
<p id="par_id361589200129686" class="paragraph" dir="auto"><span class="emph">before</span>: The name (as a string) or position (as an integer starting at 1) of an existing menu before which the new menu will be placed. If no value is defined for this argument, the menu will be created at the last position in the menubar.</p>
<p id="par_id361589200122507" class="paragraph" dir="auto"><span class="emph">submenuchar</span>: The delimiter used to create menu trees when calling methods as <span class="literal">AddItem</span> from the <span class="literal">Menu</span> service. The default value is ">".</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 oDoc as Object, oMenu as Object
Set oDoc = CreateScriptService("Document")
Set oMenu = oDoc.CreateMenu("My Menu")
With oMenu
' Add items to the menu
.AddItem("Item A")
.AddItem("Item B")
' ...
' After creating the menu, the service instance can be disposed of
.Dispose()
End With
</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">
doc = CreateScriptService("Document")
menu = doc.CreateMenu("My Menu")
menu.AddItem("Item A")
menu.AddItem("Item B")
# ...
menu.Dispose()
</code></pre></div>
<a id="menu_tip"></a>
<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_id271643139068194" dir="auto">Refer to the <a target="_top" href="es/text/sbasic/shared/03/sf_menu.html"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">SFWidgets.Menu</span></a> help page to learn more about how to create/remove menus in LibreOffice document windows.</p></div>
</div>
<br>
<a id="DeleteStyles"></a>
<a id="bm_id721589200120958"></a>
<meta itemprop="keywords" content="Document service,DeleteStyles">
<h2 id="hd_id261590300232440" dir="auto">DeleteStyles</h2>
<p id="par_id652699200121080" class="paragraph" dir="auto">Suppresses a single style or an array of styles given by their names within a specific styles family. Only user-defined styles may be deleted, built-in styles are ignored. It applies to all document types except <span class="literal">Base</span> and <span class="literal">FormDocument</span>.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001623997222964" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.DeleteStyles(family: str, styleslist: str[1..*])</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<a id="family"></a>
<p id="par_id361580300131416" class="paragraph" dir="auto"><span class="emph">family</span>: One of the style families present in the actual document, as a case-sensitive string. Valid family names can be retrieved using <span class="literal">StyleFamilies</span> property.</p>
<p id="par_id361589211129686" class="paragraph" dir="auto"><span class="emph">styleslist</span>: A single style name as a string or an array of style names. The style names may be localized or not. The <span class="literal">StylesList</span> is typically the output of the execution of a <span class="literal">Styles()</span> method.</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">
' Removing unused paragraph styles
Const family = "ParagraphStyles"
aList = oDoc.Styles(family, used := False, userDefined := True)
oDoc.DeleteStyles(family, aList)
</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">
# Removing styles according to a prefix
a_list = doc.Styles('ParagraphStyles', namepattern = "Py*")
doc.Styles('ParagraphStyles', a_list)
</code></pre></div>
<a id="Echo"></a>
<a id="bm_id721985200199205"></a>
<meta itemprop="keywords" content="Document service,Echo">
<h2 id="hd_id261589202103395" dir="auto">Echo</h2>
<p id="par_id156589200192258" class="paragraph" dir="auto">Suspends user interface (UI) updates during the execution of a macro. Optionally, the mouse pointer can be changed into an hourglass while UI updates are suspended.</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_id851688837646904" dir="auto">This method may provide some performance benefits for macros that perform numerous operations that require UI updates.</p></div>
</div>
<br>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622824461169" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Echo(echoon: bool = True, hourglass: bool = False)</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id211635436910325" class="paragraph" dir="auto"><span class="emph">echoon</span>: Specify <span class="literal">False</span> to suspend UI updates. The default value is <span class="literal">True</span>, which enables real time UI updates.</p>
<p id="par_id141635436912288" class="paragraph" dir="auto"><span class="emph">hourglass</span>: Specify <span class="literal">True</span> to change the mouse pointer to an hourglass (Default = <span class="literal">False</span>).</p>
<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_id741689124521451" dir="auto">Moving the mouse pointer after it changed to an hourglass may cause it to switch to a different pointer depending on its new background.</p></div>
</div>
<br>
<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">
' Suspends UI updates and change mouse pointer to an hourglass
oDoc.Echo(EchoOn := False, HourGlass := True)
' Other macro commands
' ...
' Restores UI updates and mouse pointer
oDoc.Echo()
</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">
doc.Echo(echoon = False, hourglass = True)
...
doc.Echo()
</code></pre></div>
<a id="ExportAsPDF"></a>
<a id="bm_id721985200121025"></a>
<meta itemprop="keywords" content="Document service,ExportAsPDF">
<h2 id="hd_id261589202100695" dir="auto">ExportAsPDF</h2>
<p id="par_id156589200123048" class="paragraph" dir="auto">Exports the document directly as a PDF file to the specified location. Returns <span class="literal">True</span> if the PDF file was successfully created.</p>
<p id="par_id811638276067119" class="paragraph" dir="auto">The export options can be set either manually using the <span class="menuitem">File - Export As - Export as PDF</span> dialog or by calling the methods <span class="literal">GetPDFExportOptions</span> and <span class="literal">SetPDFExportOptions</span> from the <a target="_top" href="es/text/sbasic/shared/03/sf_session.html">Session</a> service.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622827826679" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.ExportAsPDF(filename: str, overwrite: bool = False, opt pages: str, opt password: str, opt watermark: str): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id211635436910641" class="paragraph" dir="auto"><span class="emph">filename</span>: The full path and file name of the PDF to be created. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
<p id="par_id141635436912005" class="paragraph" dir="auto"><span class="emph">overwrite</span>: Specifies if the destination file can be overwritten (Default = <span class="literal">False</span>). An error will occur if <span class="literal">overwrite</span> is set to <span class="literal">False</span> and the destination file already exists.</p>
<p id="par_id141635436913587" class="paragraph" dir="auto"><span class="emph">pages</span><span class="emph"></span>: String specifying which pages will be exported. This argument uses the same notation as in the dialog <span class="menuitem">File - Export As - Export as PDF</span>.</p>
<p id="par_id141635436919655" class="paragraph" dir="auto"><span class="emph">password</span><span class="emph"></span>: Specifies a password to open the PDF file.</p>
<p id="par_id141635436913365" class="paragraph" dir="auto"><span class="emph">watermark</span>: Text to be used as watermark in the PDF file, which will be drawn in every page of the resulting PDF.</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_id301638234284727" class="paragraph" dir="auto">The following example exports the current document as a PDF file, defines a password and overwrites the destination file if it already exists.</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">
oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf", Password := "1234", Overwrite := True)
</code></pre></div>
<p id="par_id311638276257020" class="paragraph" dir="auto">The code snippet below gets the current PDF export options and uses them to create the PDF file.</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">
Dim exportSettings as Object, oSession as Object
oSession = CreateScriptService("Session")
exportSettings = oSession.GetPDFExportOptions()
' Sets to True the option to export comments as PDF notes
exportSettings.ReplaceItem("ExportNotes", True)
oSession.SetPDFExportOptions(exportSettings)
oDoc.ExportAsPDF("C:\User\Documents\myFile.pdf")
</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">
doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf", password = "1234", overwrite = True)
</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">
session = CreateScriptService("Session")
exportSettings = oSession.GetPDFExportOptions()
exportSettings.ReplaceItem("ExportNotes", True)
session.SetPDFExportOptions(exportSettings)
doc.ExportAsPDF(r"C:\User\Documents\myFile.pdf")
</code></pre></div>
<a id="PrintOut"></a>
<a id="bm_id721985200121249"></a>
<meta itemprop="keywords" content="Document service,PrintOut">
<h2 id="hd_id261589202101415" dir="auto">PrintOut</h2>
<p id="par_id156589200121138" class="paragraph" dir="auto">This method sends the contents of the document to the default printer or to the printer defined by the <span class="literal">SetPrinter</span> method.</p>
<p id="par_id981611169416934" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the document was successfully printed.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622827822169" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.PrintOut(pages: str = "", copies: num = 1): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id211635436910093" class="paragraph" dir="auto"><span class="emph">pages</span>: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages.</p>
<p id="par_id141635436912146" class="paragraph" dir="auto"><span class="emph">copies</span>: The number of copies. Default is 1.</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 oDoc.PrintOut("1-4;10;15-18", Copies := 2) Then
' ...
End If
</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 doc.PrintOut(copies=3, pages='45-88'):
# ...
</code></pre></div>
<a id="RemoveMenu"></a>
<a id="bm_id721589200129148"></a>
<meta itemprop="keywords" content="Document service,RemoveMenu">
<h2 id="hd_id261589200121147" dir="auto">RemoveMenu</h2>
<p id="par_id651589200165470" class="paragraph" dir="auto">Quita un menú de nivel superior de la barra de menús de la ventana de un documento indicado.</p>
<p id="par_id981611149610695" class="paragraph" dir="auto">Returns <span class="literal">True</span> if the specified menu could be removed. If the specified menu does not exist, the method returns <span class="literal">False</span>.</p>
<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_id571643121106014" dir="auto">This method can be used to remove any menu entry from the document window, including default menus. However, none of these changes in the menubar are saved to the document or to the application settings. To restore the menubar to the default settings, simply close and reopen the document window.</p></div>
</div>
<br>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001622887065864" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.RemoveMenu(menuheader: str): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id361589200121156" class="paragraph" dir="auto"><span class="emph">menuheader</span>: The toplevel name of the menu to be removed.</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 oDoc as Object
Set oDoc = CreateScriptService("Document")
oDoc.RemoveMenu("My Menu")
</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">
doc = CreateScriptService("Document")
doc.RemoveMenu("My Menu")
</code></pre></div>
<div class="embedded">
<a id="menu_tip"></a>
<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_id271643139068194" dir="auto">Refer to the <a target="_top" href="es/text/sbasic/shared/03/sf_menu.html"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">SFWidgets.Menu</span></a> help page to learn more about how to create/remove menus in LibreOffice document windows.</p></div>
</div>
<br>
</div>
<a id="RunCommand"></a>
<a id="bm_id601589202413561"></a>
<meta itemprop="keywords" content="Document service,RunCommand">
<h2 id="hd_id611589202413141" dir="auto">RunCommand</h2>
<p id="par_id991589202413257" class="paragraph" dir="auto">Runs a UNO command on the document window associated with the service instance. A few typical commands are: Save, SaveAs, ExportToPDF, Undo, Copy, Paste, etc.</p>
<p id="par_id261589202778896" class="paragraph" dir="auto">The document itself does not need to be active to be able to run commands.</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">The following example runs the <span class="literal">SelectData</span> command in a Calc file named "MyFile.ods", which will result in the selection of the data area based on the currently selected cell. Note that this command does not require any arguments.</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 oDoc = CreateScriptService("Document", "MyFile.ods")
oDoc.RunCommand("SelectData")
</code></pre></div>
<p id="par_id371644184276886" class="paragraph" dir="auto">Below is an example that runs the UNO command <span class="literal">ReplaceAll</span> and passes values for its arguments <span class="literal">SearchString</span> and <span class="literal">ReplaceString</span>. Running this command will replace all occurrence of the string "abc" by "ABC" in the current sheet.</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:
' SearchString = "abc"
' ReplaceString = "ABC"
oDoc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC")
</code></pre></div>
<p id="par_id41644184549167" class="paragraph" dir="auto">Note that calling the command <span class="literal">ReplaceAll</span> without arguments will open the <span class="menuitem">Find and Replace</span> dialog.</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">
doc = CreateScriptService("Document", "MyFile.ods")
doc.RunCommand("SelectData")
</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">
doc.RunCommand(".uno:ReplaceAll", "SearchString", "abc", "ReplaceString", "ABC")
</code></pre></div>
<p id="par_id811644243228448" 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">
doc.RunCommand(".uno:ReplaceAll", SearchString = "abc", ReplaceString = "ABC")
</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="Save"></a>
<a id="bm_id691589202925124"></a>
<meta itemprop="keywords" content="Document service,Save">
<h2 id="hd_id3615892029256" dir="auto">Save</h2>
<p id="par_id81589202925519" class="paragraph" dir="auto">Stores the document to the file location from which it was loaded. The method is ignored if the document was not modified.</p>
<p id="par_id731611153918907" class="paragraph" dir="auto">Returns <span class="literal">False</span> if the document could not be saved. An error is raised if the file is open as read-only, or if it is a new file that has not been saved yet.</p>
<p id="par_id211589203690937" class="paragraph" dir="auto">El documento en sí no necesita estar activo para ejecutar este método.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id711622828457342" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Save(): bool</span>
</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 Not oDoc.Save() Then
' ...
End If
</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 not doc.Save():
# ...
</code></pre></div>
<a id="SaveAs"></a>
<a id="bm_id141589203370367"></a>
<meta itemprop="keywords" content="Document service,SaveAs">
<h2 id="hd_id161589203370594" dir="auto">SaveAs</h2>
<p id="par_id121589203370778" class="paragraph" dir="auto">Stores the document to the given file location. The new location becomes the new file name on which simple Save method calls will be applied.</p>
<p id="par_id31611154475602" class="paragraph" dir="auto">Devuelve <span class="literal">Falso</span> si el documento no pudo guardarse. Se emite un error si se rechaza sobrescribir el archivo de destino o cuando el atributo «de solo lectura» está activo en el archivo de destino.</p>
<p id="par_id391589203370902" class="paragraph" dir="auto">El documento en sí no necesita estar activo para ejecutar este método.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id561622828596238" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.SaveAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id331589203370950" class="paragraph" dir="auto"><span class="emph">filename</span>: A string containing the file name to be used. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
<p id="par_id631589204010142" class="paragraph" dir="auto"><span class="emph">overwrite</span>: If <span class="literal">True</span>, the destination file may be overwritten (default = <span class="literal">False</span>).</p>
<p id="par_id811589204084107" class="paragraph" dir="auto"><span class="emph">password</span> (*): A non-space string to protect the document.</p>
<p id="par_id451589204163772" class="paragraph" dir="auto"><span class="emph">filtername</span> (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist.</p>
<p id="par_id981589204207800" class="paragraph" dir="auto"><span class="emph">filteroptions</span> (*): An optional string of options associated with the filter.</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">
oDoc.SaveAs("C:\Documents\NewCopy.odt", overwrite := 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">
doc.SaveAs(r"C:\Documents\NewCopy.odt", overwrite = True)
</code></pre></div>
<a id="SaveCopyAs"></a>
<a id="bm_id71158920514765"></a>
<meta itemprop="keywords" content="Document service,SaveCopyAs">
<h2 id="hd_id811589205147824" dir="auto">SaveCopyAs</h2>
<p id="par_id911589205147502" class="paragraph" dir="auto">Almacena una copia de o exporta el documento en la ubicación de archivo que se indique. El archivo actual no se modifica.</p>
<p id="par_id381611154800685" class="paragraph" dir="auto">Devuelve <span class="literal">Falso</span> si el documento no pudo guardarse. Se emite un error si se rechaza sobrescribir el archivo de destino o cuando el atributo «de solo lectura» está activo en el archivo de destino.</p>
<p id="par_id11589205147643" class="paragraph" dir="auto">El documento en sí no necesita estar activo para ejecutar este método.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id561622828596855" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.SaveCopyAs(filename: str, overwrite: bool = False, password: str = '', filtername: str = '', filteroptions: str = ''): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id301589205147697" class="paragraph" dir="auto"><span class="emph">filename</span>: A string containing the file name to be used. It must follow the <span class="literal">SF_FileSystem.FileNaming</span> notation.</p>
<p id="par_id851589205147348" class="paragraph" dir="auto"><span class="emph">overwrite</span>: If <span class="literal">True</span>, the destination file may be overwritten (default = <span class="literal">False</span>).</p>
<p id="par_id821589205147330" class="paragraph" dir="auto"><span class="emph">password</span> (*): A non-space string to protect the document.</p>
<p id="par_id67158920514729" class="paragraph" dir="auto"><span class="emph">filtername</span> (*): The name of a filter that should be used for saving the document. If this argument is passed, then the filter must exist.</p>
<p id="par_id881589205147911" class="paragraph" dir="auto"><span class="emph">filteroptions</span> (*): An optional string of options associated with the filter.</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">
oDoc.SaveCopyAs("C:\Documents\Copy2.odt", Overwrite := 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">
doc.SaveCopyAs(r"C:\Documents\Copy2.odt", overwrite = True)
</code></pre></div>
<a id="SetPrinter"></a>
<a id="bm_id71158921504765"></a>
<meta itemprop="keywords" content="Document service,SetPrinter">
<h2 id="hd_id811589502147824" dir="auto">SetPrinter</h2>
<p id="par_id911298505147502" class="paragraph" dir="auto">Defines the printer options for the document.</p>
<p id="par_id381651114800685" class="paragraph" dir="auto">Returns <span class="literal">True</span> when successful.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id261652828596855" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.SetPrinter(opt printer: str, opt orientation: str, paperformat: str): bool</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<a id="setPrinterArgs"></a>
<p id="par_id301589205741697" class="paragraph" dir="auto"><span class="emph">printer</span>: The name of the printer queue where to print to. When absent, the default printer is set.</p>
<p id="par_id851985205147348" class="paragraph" dir="auto"><span class="emph">orientation</span>: Either <span class="literal">PORTRAIT</span> or <span class="literal">LANDSCAPE</span>. When absent, left unchanged with respect to the printer settings.</p>
<p id="par_id821985205147330" class="paragraph" dir="auto"><span class="emph">paperformat</span>: Specifies the paper format as a string value that can be either <span class="literal">A3</span>, <span class="literal">A4</span>, <span class="literal">A5</span>, <span class="literal">LETTER</span>, <span class="literal">LEGAL</span> or <span class="literal">TABLOID</span>. Left unchanged when absent.</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">
oDoc.SetPrinter(Orientation := "PORTRAIT")
</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">
doc.SetPrinter(paperformat='TABLOID')
</code></pre></div>
<a id="Styles"></a>
<a id="bm_id721589200120958"></a>
<meta itemprop="keywords" content="Document service,Styles">
<h2 id="hd_id262600300121440" dir="auto">Styles</h2>
<p id="par_id652600200121080" class="paragraph" dir="auto">Retrieves a list of styles matching an optional compound criteria, the returned array may be empty. It applies to all document types except <span class="literal">Base</span>.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001623997333964" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Styles(family, opt namepattern: str, opt used: bool, opt userdefined: bool, opt parentstyle: str, opt category: str): str[0..*])</span>
</p>
<div class="embedded">
<a id="family"></a>
<p id="par_id361580300131416" class="paragraph" dir="auto"><span class="emph">family</span>: One of the style families present in the actual document, as a case-sensitive string. Valid family names can be retrieved using <span class="literal">StyleFamilies</span> property.</p>
</div>
<p id="par_id361589322129686" class="paragraph" dir="auto"><span class="emph">category</span>: A case-insensitive string: TEXT, CHAPTER, LIST, INDEX, EXTRA, HTML. For their respective meanings, refer to <a target="_blank" href="https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1style_1_1ParagraphStyleCategory.html">paragraph style category</a> API documentation.</p>
<p id="par_id921701269531603" class="paragraph" dir="auto">This argument is ignored when the Family differs from "ParagraphStyles".</p>
<p id="par_id472589322129797" class="paragraph" dir="auto"><span class="emph">namepattern</span>: A filter on the style names, as a case-sensitive string pattern. The names include the internal and localized names.</p>
<p id="par_id551701269163643" class="paragraph" dir="auto">Admitted wildcard are:</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_id481701269193780" class="listitem" dir="auto">the "?" representing any single character.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id821701269197990" class="listitem" dir="auto">the "*" representing zero, one, or multiple characters</p>
</li>
</ul>
<p id="par_id583589322129808" class="paragraph" dir="auto"><span class="emph">parentstyle</span>: When present, only the children of the given, localized or not, parent style name are retained.</p>
<p id="par_id694589322129919" class="paragraph" dir="auto"><span class="emph">used</span>: When <span class="literal">True</span>, the style must be used in the document, when absent the argument is ignored.</p>
<p id="par_id705589322129020" class="paragraph" dir="auto"><span class="emph">userdefined</span>: When <span class="literal">True</span>, the style must have been added by the user, either in the document or its template, when absent, the argument is ignored.</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 vStyles As Variant
vStyles = oDoc.Styles("ParagraphStyles") 'All styles in the family
vStyles = oDoc.Styles("ParagraphStyles", "H*") 'Heading, Heading 1, ...
vStyles = oDoc.Styles("ParagraphStyles", Used := False, UserDefined := True) ' All user-defined styles that are not used
vStyles = oDoc.Styles("ParagraphStyles", ParentStyle := "Standard") ' All styles derived from the 'Default Paragraph Style'
</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">
vStyles = doc.Styles('ParagraphStyles') #All styles in the family
vStyles = doc.Styles('ParagraphStyles', 'H*') #Heading, Heading 1, ...
vStyles = doc.Styles('ParagraphStyles', Used = False, UserDefined = True) # All user-defined styles that are not used
vStyles = doc.Styles('ParagraphStyles', ParentStyle = 'Standard") # All styles derived from the "Default Paragraph Style"
</code></pre></div>
<a id="Toolbars"></a>
<a id="bm_id721580310120958"></a>
<meta itemprop="keywords" content="Document service,Toolbars">
<a id="SF_Toolbars"></a>
<h2 id="hd_id261501400121339" dir="auto">Toolbars</h2>
<p id="par_id091612259727155" class="paragraph" dir="auto">This method returns either a list of the available toolbar names in the actual document or an instance <a target="_top" href="es/text/sbasic/shared/03/sf_toolbar.html"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">SFWidgets.Toolbar</span></a> service.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id2111634997222964" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Toolbars(opt ToolbarName: str): uno</span><br>
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.Toolbars(): str[0..]</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id361580321120786" class="paragraph" dir="auto"><span class="emph">ToolbarName</span>: The usual name of one of the available toolbars.</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 oToolbar As Object
Set oToolbar = oDoc.Toolbars("myToolbar")
</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">
a_list = doc.Toolbars()
</code></pre></div>
<a id="XStyles"></a>
<a id="bm_id721589200120958"></a>
<meta itemprop="keywords" content="Document service,XStyles">
<h2 id="hd_id261590300121339" dir="auto">XStyles</h2>
<p id="par_id091612259616155" class="paragraph" dir="auto">This method returns the UNO representation of a given style for all document types except <span class="literal">Base</span>. <span class="literal">Nothing</span> is returned when the <span class="literal">StyleName</span> does not exist in the given family.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id1001634997222964" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.XStyles(family: str, stylename: str): uno</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<div class="embedded">
<a id="family"></a>
<p id="par_id361580300131416" class="paragraph" dir="auto"><span class="emph">family</span>: One of the style families present in the actual document, as a case-sensitive string. Valid family names can be retrieved using <span class="literal">StyleFamilies</span> property.</p>
</div>
<p id="par_id361589211120786" class="paragraph" dir="auto"><span class="emph">stylename</span>: One of the styles present in the given family, as a case-sensitive string. The <span class="literal">StyleName</span> may be localized or not.</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 oStyle As Object
Set oStyle = oDoc.XStyle("ParagraphStyle", "Heading 2")
</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">
oStyle = doc.XStyle('ParagraphStyle', 'Heading 2')
</code></pre></div>
<div class="embedded">
<a id="SF_InternalUse"></a>
<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_id851506659675843" dir="auto">Todas las rutinas o identificadores BASIC de <span class="literal">ScriptForge</span> precedidas por guion bajo «_» están reservadas para uso interno. No deben utilizarse en macros BASIC o secuencias Python.</p></div>
</div>
<br>
</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_dictionary.html"><span class="literal">ScriptForge</span>.<span class="literal">Dictionary</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_ui.html">Servicio <span class="literal">ScriptForge</span>.<span class="literal">UI</span></a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_menu.html"><span class="literal">SFWidgets</span>.<span class="literal">Menu</span> service</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_document.xhp" target="_blank">/text/sbasic/shared/03/sf_document.xhp</a></p>
<p dir="auto">Title is: Servicio SFDocuments.Document</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>