Unable to generate valid macros using ChatGPT and Grok. Both report interpreter issues!

I’m running a Basic macro in LibreOfficeDev 26.0.0.0 alpha0+ to optimize table column widths in Writer, but 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. Previous attempts also hit errors: “Internal error $(ARG1)” when iterating UNO collections (e.g., getPropertySetInfo().getProperties(), getAvailableServiceNames()), zero Height/Width values, and missing methods (isInTable, getServiceName).

Test setup:

  • LibreOfficeDev 26.0.0.0 alpha0+ (exact build: [add if known]).
  • Writer document with a 2x3 table, no merged cells, text content: “A”, “Long text”, “Very long text”.
  • Cursor inside table.
  • Macro: DebugTableObjectsMinimal (attached).

Debug output (below) shows:

  • Table access works (Name, Width get/set).
  • getCellNames() confirms 2 columns, 3 rows.
  • Rows.getByIndex and getCellByName("A1") work.
  • Columns.getByIndex(i) returns Null, blocking column width adjustments.

Is this a known issue in 26 Alpha? Any workarounds for column access or optimization? Related Bugzilla: tdf#168331.

DebugData.zip (39.5 KB)
The attachment contains-

  1. Test file
  2. Test macro
  3. Output of the macro

Click inside the second (2x3) table and then run the debug macro.

This is only one sample problem: Both ChatGPT and Grok are facing a lot of problems while creating macros.

for reference, the answer from tdf#168331
image

Robert Großkopf 2025-09-09 15:07:10 UTC
This isn’t a bug. Seems you (and ChatGPT) will need help for getting it work. You could create a new entry in https://ask.libreoffice.org/ instead. Most answers will appear in English - Ask LibreOffice

so are we ! :expressionless:

hope you can teach AI with this https://wiki.documentfoundation.org/API/Samples/Java/Writer/TextTable#Columns_width
https://stackoverflow.com/questions/19605183/libreoffice-4-1-writer-macro-to-adjust-column-widths-in-tables

FTR: beyond tdf#168331, OP has also created tdf#168342.

If you find flaws in AI tools, why not chat with AI?

1 Like

https://ask.libreoffice.org/faq

I found the problem while using the AI tools.

Apparently, the problem is in LO, not in ChatGPT/Grok.
They are trying some valid-looking attributes and methods, which are there in the documentation.
But the attributes and methods do not behave as expected.
So they try to code it differently, but again face another problem.
What else can we expect from AI?

AI tools read the latest documentation and then code.
So the solution is required from the coders and/or documenters.

I do not know how that is even supposed to work.
With AI, I can do macros.
I cannot ask ChatGPT to go deep in LO’s Java code and repair it!

Title of this thread might be misleading. So I will only write something for column width:

	REM Create column width	
	inWidthRel = oTable.TableColumnRelativeSum '100%
	inWidthTab = 10
	oSeparators = oTable.TableColumnSeparators
	FOR k = 0 TO UBound(arColWidth()) - 1
		sep = oSeparators(k)
		sep.Position = arColWidth(k) / inWidthTab * inWidthRel
		oSeparators(k) = sep
	NEXT
	oTable.TableColumnSeparators = oSeparators

This works here without any problem. I first create an array containing all the width I need and then I create the column separators by the values of this array. Would help to create invoices here with different column width for different content.
.
The bug you wrote is about another problem. But why should anything be a bug, which has been created by ChatGPT. Or didn’t I notice ChatGPT is a new component of LibreOffice?

1 Like

Read Andrew Pitonyak’s Useful Macro Information subchapter 8.7.

The .Columns property of a TexTable has about 0 (zero) useful properties. (The .Count may be one, however.)
This is possibly due to doubtable design of the software, but it’s not a bug.

Tell your AI chat-bots, they should also read Andew’s famous texts.

1 Like