# How to use the Python scripting capabilities of LibreOffice Impress to set the background color of the table cell where the cursor is currently located

**URL:** <https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665>\
**Category:** Development\
**Created:** [May 31, 2024, 2:40am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665 "2024-05-31T02:40:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnhy520](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/mnhy520/32/1228_2.png) [@mnhy520](https://forum.collaboraonline.com/u/mnhy520)\
**Post date:** [May 31, 2024, 2:40am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/1 "2024-05-31T02:40:29Z")

</div>

Hello everyone, I want to use the Python scripting capabilities of LibreOffice Impress to set the background color of the table cell where the cursor is currently located. I have been searching for a long time but couldn’t find a way to do this. Is there any solution? Thank you.

---

<div class="post-metadata">

**Author:** ![vmiklos](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/vmiklos/32/787_2.png) [@vmiklos](https://forum.collaboraonline.com/u/vmiklos)\
**Post date:** [May 31, 2024, 8:02am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/2 "2024-05-31T08:02:06Z")

</div>

In Basic, you can do something like:

```auto
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "FillStyle"
args(0).Value = 1 ' Solid
dispatcher.executeDispatch(document, ".uno:FillStyle", "", 0, args)
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "FillColor.Color"
args2(0).Value = 16776960
dispatcher.executeDispatch(document, ".uno:FillColor", "", 0, args2)

```

Can you try the equivalent of that in Python?

---

<div class="post-metadata">

**Author:** ![mnhy520](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/mnhy520/32/1228_2.png) [@mnhy520](https://forum.collaboraonline.com/u/mnhy520)\
**Post date:** [May 31, 2024, 8:33am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/3 "2024-05-31T08:33:11Z")

</div>

Thank you for your response. My use case might be more complex, not just setting the background color as simple as that. My real goal is to get the object of the table cell where the current cursor is located.

---

<div class="post-metadata">

**Author:** ![cornouws](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cornouws](https://forum.collaboraonline.com/u/cornouws)\
**Post date:** [June 7, 2024, 8:58pm UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/4 "2024-06-07T20:58:47Z")

</div>

Hi mnhy520,

Something in the direction you ask:

`ThisComponent.CurrentController.Selection.getByIndex(0).Model.Columns.getByIndex(0).getCellByPosition (0,0).setPropertyValue( "CharBackColor", 654456)`

You can use Xray in de basic editor to find your way in all objects, properties, methods.  
HTH,  
Cor

---

<div class="post-metadata">

**Author:** ![mnhy520](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/mnhy520/32/1228_2.png) [@mnhy520](https://forum.collaboraonline.com/u/mnhy520)\
**Post date:** [June 11, 2024, 9:42am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/5 "2024-06-11T09:42:55Z")

</div>

Hi cornouws,  
I’m not trying to get the cell at coordinate 0,0. What I’m trying to do is to get the cell where the current cursor is located, so I don’t know what the 0,0 coordinate refers to here.getCellByPosition (0,0)

---

<div class="post-metadata">

**Author:** ![cornouws](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cornouws](https://forum.collaboraonline.com/u/cornouws)\
**Post date:** [June 11, 2024, 4:17pm UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/6 "2024-06-11T16:17:10Z")

</div>

Yes, I’m aware that my answer is only a hint in a direction.  
I suggested to search with using Xray tool in basic. But to be honest, I do not have the idea that there is a something as a ‘current selection’ that refers to e.g. a text or a cell range, as is the case in Calc…

---

<div class="post-metadata">

**Author:** ![mnhy520](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/mnhy520/32/1228_2.png) [@mnhy520](https://forum.collaboraonline.com/u/mnhy520)\
**Post date:** [June 13, 2024, 6:21am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/7 "2024-06-13T06:21:09Z")

</div>

Okay, thank you for your help

---

<div class="post-metadata">

**Author:** ![cornouws](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cornouws](https://forum.collaboraonline.com/u/cornouws)\
**Post date:** [June 14, 2024, 8:09am UTC](https://forum.collaboraonline.com/t/how-to-use-the-python-scripting-capabilities-of-libreoffice-impress-to-set-the-background-color-of-the-table-cell-where-the-cursor-is-currently-located/2665/8 "2024-06-14T08:09:37Z")

</div>

> [@cornouws](#):
>
> But to be honest, I do not have the idea that there is a something as a ‘current selection’ that refers to e.g. a text or a cell range, as is the case in Calc…

Having said that: it might well be that there is some interface/service provider that does give methods needed, but finding is the challenge (maybe with [opengrock](https://opengrok.libreoffice.org/)?)
