Bug 168342 - Macro to manipulate table fails in Writer
Summary: Macro to manipulate table fails in Writer
Status: RESOLVED DUPLICATE of bug 51925
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-10 09:49 UTC by NarayanAras
Modified: 2025-09-14 09:49 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Includes the test file, the debug macro, and its output (39.50 KB, application/x-zip-compressed)
2025-09-10 09:49 UTC, NarayanAras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NarayanAras 2025-09-10 09:49:04 UTC
Created attachment 202770 [details]
Includes the test file, the debug macro, and its output

In LibreOfficeDev 26.0.0.0 alpha0+, a Basic macro accessing `TextTable.Columns.getByIndex(i)` returns `Null` for all columns, despite `Columns.getCount()` reporting the correct count (e.g., 2 for a 2x3 table). This prevents accessing column properties like `Width`. Other issues include "Internal error $(ARG1)" when iterating UNO collections (e.g., `getPropertySetInfo().getProperties()`, `getAvailableServiceNames()`) and zero `Height`/`Width` values in earlier attempts.

Steps to Reproduce:
1. Open Writer, create a 2x3 table (no merged cells).
2. Add text (e.g., "A", "Long text", "Very long text").
3. Place cursor in table.
4. Run attached macro (`DebugTableObjectsMinimal`).
5. Observe: `Columns.getByIndex(i)` returns `Null` for all columns, while `getCount()` reports 2.

Expected:
- `getByIndex(i)` returns valid `XTableColumn` objects with properties like `Width`.

Actual:
- `getByIndex(i)` returns `Null` (Error: 0).
- Debug output confirms table access, cell names, and row access work, but columns fail.

Attachments:
- Macro code (`DebugTableObjectsMinimal`).
- Debug output (attached).
- Test document (.odt with 2x3 table).

Related: Bug #168331[](https://bugs.documentfoundation.org/show_bug.cgi?id=168331).
Comment 1 BogdanB 2025-09-10 10:49:55 UTC
NarayanAras, what is the last version that worked well?
Comment 2 NarayanAras 2025-09-10 10:56:11 UTC
Unfortunately, I would not know.

I have been downloading and using the "Daily Master" versions for the last 2-3 years. (I update them once in 1-2 months.)

I have rarely used ChatGPT and Grok for writing macros for me.

So on both counts I do not have a pattern to report.
Comment 3 NarayanAras 2025-09-10 10:58:43 UTC
BTW, this bug itself was AI-generated. 
I am not a coder myself.

But if you want, I can run any debug macro and let you know the results.
Comment 4 Mike Kaganski 2025-09-10 11:00:03 UTC
Ref: https://ask.libreoffice.org/t/unable-to-generate-valid-macros-using-chatgpt-and-grok-both-report-interpreter-issues/126540

Looks like this is not "this used to work, but now doesn't", but rather "this code, generated by AI, doesn't work in the version I tried".
Comment 5 fpy 2025-09-10 12:29:13 UTC

*** This bug has been marked as a duplicate of bug 51925 ***
Comment 6 NarayanAras 2025-09-10 13:47:06 UTC
That is a 13-years old bug, and not resolved.

According to Grok and ChatGPT, there are many such quirks, and they are struggling with the code that is not flagged as defective in the documentation.

At least mark such methods and attributes as not available. 

I do not think AI engines can make such basic mistakes otherwise. Why waste everyone's time?
Comment 7 NarayanAras 2025-09-10 13:49:53 UTC
I can submit a summary of such quirks, collated from AI engines. I have already compiled a list of such flawed code, where ChatGPT attempted specific functions/attributed and got an error.
Comment 8 fpy 2025-09-14 09:49:36 UTC
see https://wiki.documentfoundation.org/QA/Bugzilla/Fields/Status/
RESOLVED#DUPLICATE 

(In reply to NarayanAras from comment #7)
> I can submit a summary 

feel free to do that with a clear separate report.


(In reply to NarayanAras from comment #6)
> That is a 13-years old bug, and not resolved.

duplicating is just adding noise, not speeding up the resolution.

*** This bug has been marked as a duplicate of bug 51925 ***