VB.Net Examples 4 - Copy and Paste a Table

This is the 4th Post regarding VB.Net Examples. My first posed 4 questions for which I was hoping to gain help from.

In this post I hope to gain some help in copying an existing table, content and all (assuming it has both text and images within its various cells) and then pasting it somewhere else in the Writer document being worked on.

Here’s some example code ~which does not work~

Public Shared Function CopyTable(ByRef existingTable As unoidl.com.sun.star.text.XTextTable) As unoidl.com.sun.star.text.XTextTable
    Dim newTable As unoidl.com.sun.star.text.XTextTable
    newTable = existingTable
    Return newTable
End Function

This would never work as desired because while a copy of the table is made, it isn’t a new copy, it is actually only creating a reference to the same table. Simply put the ‘new’ table has the same name as the original because it ~is~ the original.

Can anyone help provide some example VBNet code to accomplish this?