How to Insert a Bookmark in a Writer Text Table

I’m stumped by the problem of trying to insert a bookmark into a Text Table Cell in Writer.
Here’s what I’ve got so far:

  oCell = TacTable.getCellByPosition(CurCol, CurRow)
  DiagCursor = oCell.getStart()

… I can successfully insert text here

  ' Here is where we want to insert the bookmark if needed
  If QLink Then
     oCursor.gotoRange(DiagCursor.getEnd(), False)
     oBookmark = ThisComponent.createInstance("com.sun.star.text.Bookmark")
     oBookmark.setName("_Game_" & i)
    ThisComponent.Cell.insertTextContent(oCursor, oBookmark, False)
  End If

It all works fine right up to that very last line, which gives me this error:

“Text interface and cursor not related.”

I’ve tried a lot of different things here, such as:

    ThisComponent.Text.insertTextContent(oCursor, oBookmark, False)
    ThisComponent.Text.Cell.insertTextContent(oCursor, oBookmark, False)
    ThisComponent.Text.insertTextContent(DiagCursor, oBookmark, False)

Nothing I try works.
Any help here would be greatly appreciated.

I think you need to get access to the text cursor for the cell.
OOO Development Tools (OooDev) is for python but it may put you on track.
The add_bookmark() method of OooDev does so on the cursor.

This is basically how adding a bookmak is done with OooDev.

table = doc.tables[0]
cell = table["D3"]
cursor = cell.create_text_cursor()
cursor.add_bookmark("MyBookmark")

There is a Make Table that use OooDev to show the basics of working with a write table.

See Also:
add_bookmark()
create_text_cursor()

Try:

	doc = ThisComponent
	table = doc.TextTables(0)
	cell = table.getCellByPosition(0, 0)
	
	bookmark = doc.createInstance("com.sun.star.text.Bookmark")
	bookmark.Name = "MyBookMark-1"
	cell.insertTextContent(cell.Start, bookmark, False)

Please, always tell us your version of LibreOffice and OS.