If we can assume the userform is in Word then
Private Sub CommandButton1_Click()
Dim oDoc As Document
Dim oTbl As Table
Dim oRng As Range
Me.Hide
'The following template must exist at the named location
Set oDoc = Documents.Add("C:\Users\Username\Desktop\Template 1.dotx")
Set oRng = oDoc.Range
Set oTbl = oDoc.Tables.Add(Range:=oRng, _
NumRows:=3, _
NumColumns:=4, _
DefaultTableBehavior:=wdWord9TableBehavior)
oTbl.Range.Cells(1).Range.Text = Me.TextBox1.Text
'Move the start of the range to the end of the document
oRng.Collapse 0
oRng.Text = "This is after the table"
lbl_Exit:
Exit Sub
End Sub
You asked earlier what I meant by
"
Unload the form in the main code when you have finished with it and not in the userform code."
I meant that I would call the userform from a macro that would do all the processing e.g.
Option Explicit
Sub ProcessDocument()
Dim oFrm As New UserForm1 'The name of the userform
Dim oDoc As Document
Dim oTbl As Table
Dim oRng As Range
With oFrm
.Show
If .Tag = 1 Then
'The following template must exist at the named location
Set oDoc = Documents.Add("C:\Users\Username\Desktop\Template 1.dotx")
Set oRng = oDoc.Range
Set oTbl = oDoc.Tables.Add(Range:=oRng, _
NumRows:=3, _
NumColumns:=4, _
DefaultTableBehavior:=wdWord9TableBehavior)
oTbl.Range.Cells(1).Range.Text = .TextBox1.Text
'Move the start of the range to the end of the document
oRng.Collapse 0
oRng.Text = "This is after the table"
End If
End With
Unload oFrm
lbl_Exit:
Set oFrm = Nothing
Set oDoc = Nothing
Set oTbl = Nothing
Set oRng = Nothing
Exit Sub
End Sub
and in the userform I would have simply
Option Explicit
Private Sub CommandButton1_Click() 'Continue
Me.Tag = 1
Me.Hide
lbl_Exit:
Exit Sub
End Sub
Private Sub CommandButton2_Click() 'Cancel
Me.Tag = 0
Me.Hide
lbl_Exit:
Exit Sub
End Sub