![]() |
#4
|
|||
|
|||
![]()
Ah. That explains it.
The following vba code works Code:
Sub shape_test() Dim shape As shape Dim i As Long For i = 1 To 3 Selection.Text = "New Page " & i Selection.Collapse Direction:=wdCollapseEnd ' the shapes get anchored to this paragraph below, not to the text above. Why? ' If I take out the paragraph, all 3 sets of shapes stack on each other, ' on the very last page of the set. Why? Selection.InsertParagraph Set shape = ActiveDocument.Shapes.AddShape(msoShapeRectangle, 100, 100, 300, 300) ' don't generate a new page after the last page of the series ' If (i < npages) Then Selection.Collapse Direction:=wdCollapseEnd Selection.InsertBreak Type:=wdPageBreak ' End If ' End If Next End Sub 1. New Page 1 is inserted and highlighted as the selection range 2. Following the collapse the insertion point is on the left hand side of the paragraph marker. 3. Inserting a paragraph marker puts it on the left hand side of the existing paragraph marker and highlights the inserted paragraph marker as the selected range (as per MS help on .insertParagraph) 4. Inserting the shape puts the anchor at the start of the paragraph 'New Page 1'. The selection range is now the inserted shape. 5. The range is again collapsed so that it does not encompass the inserted shape 6. The insert break works fine and the whole process above is repeated for the next page. I hope this makes things clearer. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word2010 Text Anchor - How To Do It? | bluenite | Word | 3 | 05-07-2018 05:04 AM |
How to change size / shape of a shape in a stencil | tomgoodell | Visio | 1 | 06-30-2016 04:40 AM |
![]() |
Deltaj | Word VBA | 1 | 12-05-2014 01:56 AM |
Text boxes don't anchor properly in PPT '08 | noni | PowerPoint | 0 | 11-13-2011 09:16 AM |
Question about Tools>Rules and Alerts>E-mail Rules | RichGuard | Outlook | 0 | 09-02-2010 05:19 PM |