Cannot retrieve text from text box in dialog

I have a calc sheet with a form that I wish to revise via dialog box. The macro will update the form okay, the only issue is that it is not retrieving the text from the controls in the dialog. I tried this simpler example and got the same issue, will not receive the text.

Sub GetTextboxText
’ Load the dialog library (if necessary)
DialogLibraries.LoadLibrary(“Standard”)

’ Load your dialog
Dim myDialog As Object
myDialog = CreateUnoDialog( DialogLibraries.Standard.Dialog2 )

’ Get a handle to the textbox control
Dim myTextBox As Object
myTextBox = myDialog.getControl(“TextField1”) ’ Replace “TextField1” with your textbox name

’ Get the text from the textbox
Dim textboxContent As String
textboxContent = myTextBox.Text

’ Display the text (for demonstration)
MsgBox("Text from textbox: " & textboxContent)

End Sub

I also tried using the Model.getbyName method and the same thing happens. I do not get an error, I get a pop up msgbox that read "Text from textbox: " and NOTHING. I typed the text “test” into the box and I can still see it there, it is just not being retrieved in the macro. What is missing?

myDialog = CreateUnoDialog( DialogLibraries.Standard.Dialog2 )
x = myDialog.execute()
if x = 1 then
   REM confirmed with a button of type "OK":
   sText = myDialog.getControl("TextField1").getText()
else
  sText = "Canceled"
End If
Msgbox sText

Thank you. I was definitely missing the fact that I could(should? need to?) do this in the same Sub that executes the dialog. That has my test working and should make my more complicated project much simpler!