Word Automation frames

Hi, A few years ago with the old Real Studio I prepared a word document with several pages, on the first page I inserted an image, some text and a table, then I enclosed everything in two frames, it worked well with word 2003 and 2010. code the same even if it works for most of the document it does not work well with frames (Xojo 2019 Word 2010) As soon as I insert the frames and insert a new page the frames are moved to the new page. This even if I insert some text after the frames, if instead I insert some text from the keyboard and then I insert a new page then okay, any ideas?
Sorry for my bad English
word = new wordapplication
word.visible = true
doc = word.documents.add
Doc.PageSetup.TopMargin =25
Doc.PageSetup.RightMargin =60
Doc.PageSetup.BottomMargin =25
Doc.PageSetup.LeftMargin =60
doc.PageSetup.FooterDistance =15
word.Selection.ParagraphFormat.Alignment =1
Word.Selection.Font.Size = 16
Word.Selection.Font.Color =&H0000FF
word.Selection.TypeText “test writing text”+EndOfLine
Word.ActiveDocument.Shapes.AddShape(Office.msoShapeRoundedRectangle, 65, 60, 490,720)
Word.ActiveDocument.Shapes(1).Fill.Transparency = 1
Word.ActiveDocument.Shapes(1).Line.ForeColor = &H0000FF
Word.ActiveDocument.Shapes(1).Adjustments.Item(1) = 0.03
word.ActiveDocument.Shapes.AddShape(Office.msoShapeRoundedRectangle, 75,70, 470,700)
word.ActiveDocument.Shapes(2).Fill.Transparency = 1
word.ActiveDocument.Shapes(2).Line.ForeColor = &HFF0000
word.ActiveDocument.Shapes(2).Adjustments.Item(1) = 0.025
Word.Selection.Font.Size = 12
Word.Selection.Font.Color =&HFF0000
word.Selection.TypeText “try writing other text”
rem ok before the new page

Hello Mario,

My guess is that the reason the frames are added to the cursor is at the beginning of the document. When I change the position of the cursor to the end of the document with

…then the frame remains on the first document. Is this what you wanted?

Here is slightly modified code that shows text and the frames on the first page, and adds text on the second page.

1 Like

Thank you Eugene I will never forget this instruction
word.Selection.EndKey (Office.wdStory)

1 Like