Now I see what was throwing me off. When learning a new concept, I always try to minimize everything to bare bones, and then build on it. Unfortunately, in this case it took me a wrong path. I was creating a form and then adding a button do that form, not to a drawpage. When I looked at the drawpage count property just now, it turns out it’s 0. However, what is interesting is that when I created the form and button, it was showing up in the navigator. But when I selected properties of the button, it did not have any way of manually entering the size or the position. The values were completely omitted.
Const SheetNumber = 4
Const FormName = "TestForm"
Const ButtonName = "btnTestButton"
Dim oForms as Object
oForms = ThisComponent.Sheets.getByIndex(SheetNumber).DrawPage.Forms
With oForms
.insertByName(FormName, CreateUnoService("com.sun.star.form.component.Form"))
.getByName(FormName).insertByName(ButtonName, CreateUnoService("com.sun.star.form.component.CommandButton"))
End with
With oForms
.getByName(FormName).removeByName(ButtonName)
.removeByName(FormName)
End With
I wonder if there is a way of still utilizing my code somehow and getting that button to move/resize. I see there is a method called setParent. I did not make any attempt of trying it yet, but it states that it changes the parent of the object.