# Selecting text in a document throught UNO & postMessage

**URL:** <https://forum.collaboraonline.com/t/selecting-text-in-a-document-throught-uno-postmessage/3959>\
**Category:** Development\
**Created:** [August 17, 2025, 11:01pm UTC](https://forum.collaboraonline.com/t/selecting-text-in-a-document-throught-uno-postmessage/3959 "2025-08-17T23:01:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sirceljm](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/sirceljm/32/1836_2.png) [@sirceljm](https://forum.collaboraonline.com/u/sirceljm)\
**Post date:** [August 17, 2025, 11:01pm UTC](https://forum.collaboraonline.com/t/selecting-text-in-a-document-throught-uno-postmessage/3959/1 "2025-08-17T23:01:11Z")

</div>

Hello,

I just started using collabora code. I can do some interactions through UNO and postMessage - for example selectAll.

I would like to select / find / search for speciffic text programatically, without openning any toolbars etc. Is it possible to do that in collabora office.

For the uno methods is there some kind of system on how to use them. I could not get DownSearch to work for example. Also using [LibreOffice: Main Page](https://api.libreoffice.org/docs/idl/ref/index.html) as the reference. Is it possible to use any uno function? If so I am havin trouble definign the Arguments.

Is there a way to get feedback on postMessage calls.

Best,

Matej

---

<div class="post-metadata">

**Author:** ![darshan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/darshan/32/2230_2.png) [@darshan](https://forum.collaboraonline.com/u/darshan)\
**Post date:** [August 18, 2025, 7:11am UTC](https://forum.collaboraonline.com/t/selecting-text-in-a-document-throught-uno-postmessage/3959/2 "2025-08-18T07:11:05Z")

</div>

hii @sirceljm

Good question this is one of those things that can be a bit confusing when you’re just starting with Collabora Online + UNO + `postMessage`.

1. Can you select specific text programmatically?

Yes. Collabora Online exposes most of the LibreOffice **UNO commands** (the same you’d use in a desktop LibreOffice macro).  
You can call them via `postMessage` into the editor frame. For example:

```js
document.getElementById('iframe-id').contentWindow.postMessage({
    "MessageId": "uno",
    "args": {
        "command": "SearchDialog", // or .uno:Search
        "arguments": [
            { "name": "SearchItem.SearchString", "value": "MyText" },
            { "name": "SearchItem.Backward", "value": false },
            { "name": "SearchItem.Command", "value": 3 } // 3 = find all, 1 = find next
        ]
    }
}, "*");

```

This won’t pop up the toolbar — it just runs the UNO command with the given parameters.

* * *

1. About `DownSearch` and others

Many of those names you see in the wiki (“DownSearch”, “UpSearch”, etc.) are **old-style slot commands** or macro helpers. In Collabora Online you normally stick to the **`.uno:` commands** (the desktop sends them on the wire too). For searching, the canonical command is `.uno:ExecuteSearch`.

Example:

```js
postMessage({
  "MessageId": "uno",
  "args": {
    "command": ".uno:ExecuteSearch",
    "arguments": [
      { "name": "SearchItem.SearchString", "value": "hello" },
      { "name": "SearchItem.Backward", "value": false }
    ]
  }
}, "*");

```

* * *

1. Is there a “system” for arguments?

Yes — arguments are the same **property names** the desktop UNO dispatcher uses.  
You can discover them in a few ways:

- Look at [LibreOffice source code / wiki](https://wiki.documentfoundation.org/Development/DispatchCommands) (search for `.uno:ExecuteSearch`, `.uno:GoToStartOfDoc`, etc.).
- Open LibreOffice desktop with `--record-macro`, perform an action, then inspect the recorded Basic macro. The argument names you see there are what you pass in JSON.
- In Collabora logs (`coolwsd.log`) you can see which `.uno:` commands are triggered when you click UI buttons.

* * *

### 4. Can you use _any_ UNO command?

Mostly yes, but:

- Collabora Online only implements a subset — most of the common editing/formatting/insert/search commands work.
- Things that require a modal dialog (like Tools ▸ Options) usually don’t exist in Online.
- For arguments, you must match exactly the expected property names and types (`string`, `bool`, `int`).

* * *

So: **Yes, you can select specific text programmatically**. Use `.uno:ExecuteSearch` (or `.uno:FindAll`) with the right arguments, not the old `DownSearch`.

Thanks  
Darshan

---

<div class="post-metadata">

**Author:** ![sirceljm](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/sirceljm/32/1836_2.png) [@sirceljm](https://forum.collaboraonline.com/u/sirceljm)\
**Post date:** [August 18, 2025, 12:31pm UTC](https://forum.collaboraonline.com/t/selecting-text-in-a-document-throught-uno-postmessage/3959/3 "2025-08-18T12:31:37Z")

</div>

Thanks!

I also discovered that I can call the search from the app object - like window.app.searchService.search() - probably not the most official way.

Another question, is it possible to capture events from user interaction in JS - for example user selects part of the text?
