Macro to open a form and set it's size

I have set up a macro to run when my database is opened.

SUB OpenFormsOnStart()
DIM oController AS OBJECT
DIM oForm AS OBJECT
oController = ThisDatabaseDocument.CurrentController
if Not oController.isConnected() Then oController.connect()
WAIT 1000
ThisDatabaseDocument.FormDocuments.getByName("fmSwitchboard").open
END SUB

I found the following solution to resize a form:
This opens a switchboard form. All going well so far. I would then like to size the form.

I added the RESIZE line:

SUB OpenFormsOnStart()
DIM oController AS OBJECT
DIM oForm AS OBJECT
oController = ThisDatabaseDocument.CurrentController
if Not oController.isConnected() Then oController.connect()
WAIT 1000
ThisDatabaseDocument.FormDocuments.getByName("fmSwitchboard").open
RESIZE(500,500)
END SUB

What happens is the switchboard form opens, but the database main window is shrunk to the size specified in RESIZE.
I have tried getting the focus onto the switchboard form with no success. I would be very grateful for any help with this.
Thank you very much!

This is exactly what I would expect after reading the source:

#copied from the »rezize« functiondefinition…
	vRect = thisComponent.currentController.Frame.ContainerWindow.PosSize
	intXPos=vRect.X
	intYPos=vRect.Y
	intHeight=(iHeight * 1.00)
	intWidth=(iWidth * 1.00)
	thisComponent.currentController.Frame.ContainerWindow.setPosSize(intXPos, intYPos, intWidth, intHeight, 15)

Thank you @karolus for telling me this. Does this happen because there is something in:
thisComponent.currentController.Frame.ContainerWindow.setPosSize(intXPos, intYPos, intWidth, intHeight, 15)

that refers to the main database window? In which case,is there a way I can move the focus of the setPosSize to the switchboard window that has just opened?

Thank you very much for your help.

You have to start the macro by the form you are loading. Open the form for editing. Switch to Tools → Customize → Events. Event “Open Document” I have set to get the right width, height. Zoom level and so on. Event “Document is going to be closed” will give back tool bars I have made unvisible when opening document.

SUB ToolbarsHide(oEvent AS OBJECT)
   oFrame = oEvent.Source.CurrentController.Frame
   oWin = oFrame.getContainerWindow()
   oWin.setPosSize(…)

All what you want to change you will change for oWin