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

    Handling Shapes In Footers (part II) (MS Word 2003)

    Hi (Hans, I presume!)

    I was busily implementing some code to insert a logo (shape) into a footer using Autotext. It was all going well, except following the insertion I need to change the properties of the shape, particularly the location, since I have a double-sided document and the logo is supposed to be on alternate sides i.e. a different odd and even page footer. I have a method which sets the properties ok, but getting hold of the shape object again from within the footer...

    Set r = sect.Footers(i).range
    r.Collapse direction:=wdCollapseEnd 'because the selection will be replaced with the autotext and I don't want it to delete the page number etc.
    ActiveDocument.AttachedTemplate.AutoTextEntries(Co nsts.CAutotextBrandLogoVEGA).Insert where:=r

    so the logo appears on the page, but now I need to get hold of the shape object I have just added. I thought it would be in the range.Shaperange collection but it isn't.

    Any hints? I need to pass the shape into another function as a Shape object to change the properties.

    cheers!

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    Have you checked how the autotext entry is inserted? Perhaps it's inserted inline instead of floating.

    If that is not the cause of the problem, you may have to look at the ShapeRange for the very first footer in the document, I think it contains all footer shapes.

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    Hi,

    it is inserted floating, rather than inline. I hope I can get hold of the shape object here because otherwise i will have to try to identify the shape later if I want to change it's properties. If the first footer contains all shapes (i think you're right there) then some of the shapes will be on odd pages, and other even and the properties differ for each. Therefore it's best if I can change the properties the moment I create/insert the shape, so I know definitely that I have the right one!

    cheers

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    You can select the footer, and work with the Selection object.
    Normally it's best to avoid working with selections, but this is one of the exceptions.

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    I think that you can access the most recently inserted shape as
    ActiveDocument.Shapes(ActiveDocument.Shapes.Count)

    StuartR

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    Thanks for the replies chaps.

    If i insert a (the same) logo into each type of footer (first page, odd and even) for a given section using the Autotext insert and then look at the ActiveDocument.Shapes collection, there is only one item in it. I was kinda expecting three, but on the other hand, Word seems to be really confusing in this area, so it's no surprise. In short, this means I can not access the last added logo using the ActiveDocument.Shapes collection.

    As I inserted the Autotext at the position in the footer identified by a range, I was expecting to be able to look in the shaperange collection of the footer, but this seems to be empty too. I tried selecting the footer too, but I think that only works if the header/footer view is enabled, which in my case it isn't.

    It can't be too difficult to be able to identify the shape object which has just been inserted using the Autotext function? I think I will cry now :*-(

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    This seems to be the way to return the image that was last entered into the footer. Makes sense really..!

    sect.Footers(i).shapes(sect.Footers(i).shapes.Coun t)

    cheers.

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    Just to complete this story in case anyone else ever reads it, it is not necessary to add the logo to the footers for sections where the footer is "linked to previous", if you have already added the logo to the footer of the "previous" section. Otherwise you will duplicate the shapes for those linked footers. However, if the footer is NOT linked to previous, you will have to add the shape to each footer type that is not linked.

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

    Re: Handling Shapes In Footers (part II) (MS Word 2003)

    Yes, ActiveDocument.Shapes is the collection of shapes in the body of the document; you have to refer to the Shapes collection of a specific footer.

    Also see <post:=157,050>post 157,050</post:> and the thread starting at <post:=234,390>post 234,390</post:>.

Posting Permissions

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