I am using Writer macro to create a text box located on each bottom right corner of the page.
But when the text box is created, it disappears. Only the first one being created in page 1 appears.
Sometimes the text box will appear if I click around to find it, and I can also edit it, but once I click off it, it disappears again.
I have tried Arrange > ‘Bring to front’ and Arrange > ‘In front of object’, but it still stays disappeared.
For those text boxes being disappeared, only after I manually move or resize them, they stay appear finally and show being anchored to the corresponding pages.
Below is my code, please help me to find out what I have set wrong. Thank you very much.
dim oDoc as object, oVCur as object
oDoc=ThisComponent
oVCur=oDoc.CurrentController.ViewCursor
dim Page as object
dim oStyle as object
dim pageStyle as String
pageStyle = oVCur.PageStyleName
oStyle = oDoc.StyleFamilies.getByName("PageStyles").getByName(pageStyle)
Dim myForm As Object
Dim myDimensionsForm As New com.sun.star.awt.Size
Dim myPositionForm As New com.sun.star.awt.Point
for i=1 to Page 'loop to add text box to each page
myForm = thisComponent.createInstance("com.sun.star.drawing.TextShape")
'size of text box
myDimensionsForm.Width = 1700
myDimensionsForm.Height = 800
'position of each text box relative to the size of the page
myPositionForm.X = 18000
myPositionForm.Y = 28900 + (i-1)*oStyle.height + (i-1)*800/2
myForm.Size = myDimensionsForm
myForm.Position = myPositionForm
myForm.rotateAngle = 0
myForm.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
myForm.AnchorPosition.X = 0
myForm.AnchorPosition.Y = 0
thisComponent.drawPage.add(myForm)
'each text box has string p#123, where 123 will be a variable in the future
myForm.String = Chr(112)&Chr(35)&"123"
next i