View Single Post
 
Old 12-04-2014, 02:49 PM
Deltaj Deltaj is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2014
Posts: 5
Deltaj is on a distinguished road
Default anchor addtextbox to new page

Problem: Coordinates for Textbox do not update when the focus moves to the 2nd and subsequent pages.

The documentation on AddTextbox does mention use of an Anchor, but with no example.

Previous use of an Anchor for AddPicture kindly devised in a reply by macropod on 3 Dec 2014 gave me this code which works fine to locate a picture on the correct page; the code also adds a pagebreak from the previous page.
Code:
Dim Rng As Range
With ActiveDocument
  Set Rng = .Range
  With Rng
    .Collapse direction:=wdCollapseEnd
    .InsertBreak Type:=wdPageBreak
    .Collapse direction:=wdCollapseEnd
  End With
  .Shapes.AddPicture LinkToFile:=False, Anchor:=Rng, _
    FileName:="C:\somefilename.bmp",  _
    SaveWithDocument:=True, Left:=300, Top:=1, Width:=100, Height:=100
End With
So from the above code where Anchor:= .Rng I hoped to use this in:

ActiveDocument.Shapes.AddTextbox(msoTextOrientatio nHorizontal, 74, 92, 282, 24, xxxxxx) - this is what the "Help" tells me is how to anchor the AddTextbox.

xxxxx is the anchor, but I have failed to find a syntax that works for this instruction.

The VBA "Help" could be a lot better on things like this so I am very thankful for this forum.

So how do you set up an Anchor for Textboxes please?





Last edited by macropod; 12-05-2014 at 01:52 AM. Reason: Added code tags & formatting
Reply With Quote