Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Oct 2007
    Posts
    172
    Thanks
    0
    Thanked 2 Times in 1 Post

    Determining what page a shape is on (Word 2003 VB)

    Hi, is it possible to work out what page a shape is on? I need to determine if there's an image (shape or inlineshape) on the first page of the document (in the main body, not the header/footer). I can not differentiate the shapes in any other way e.g. by name.

    I tried to loop through the shapes or inlineshapes collection and select each shape in turn (ActiveDocument.Shapes(x).Select) and then use Selection.Information(wdActiveEndAdjustedPageNumbe r) for example to determine the page number, and if it was 1 then I carry on..

    But the image.Select doesn't seem to work.

    Since Word doesn't know what Pages are, it makes it quite complicated... can anyone help?

    cheers

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Determining what page a shape is on (Word 2003

    Number of shapes on the first page of a document =
    <code>ActiveDocument.Content.Bookmarks("Page").Ran ge.ShapeRange.Count</code>

    Number of inline shapes on the first page of a document =
    <code>ActiveDocument.Content.Bookmarks("Page").Ran ge.InlineShapes.Count</code>

    StuartR

  3. #3
    2 Star Lounger
    Join Date
    Oct 2007
    Posts
    172
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: Determining what page a shape is on (Word 2003

    thanks!

    Did you just happen to know that or do you have an info source? :-)

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Determining what page a shape is on (Word 2003

    I am reasonably familiar with the word object model.

    I knew that there is a pre-defined bookmark "Page" which returns the contents of the first page in a range
    I knew that ActiveDocument.Content is a range that includes the whole document
    I knew that a bookmark has a Range property
    I knew that a range has a Shapes collection and an InlineShapes collection
    I knew that collections have a Count property

    I put all these together to produce the lines I shared with you.

    StuartR

  5. #5
    2 Star Lounger
    Join Date
    Oct 2007
    Posts
    172
    Thanks
    0
    Thanked 2 Times in 1 Post

    Re: Determining what page a shape is on (Word 2003

    Ahh ok.. I knew all of it except "I knew that there is a pre-defined bookmark "Page" which returns the contents of the first page in a range".

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Determining what page a shape is on (Word 2003

    See Predefined Bookmarks for a list of the available built-in bookmarks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •