A few newbie questions about macros

Hi guys, just thought I'd ask a few things here that I couldn't find on google or the help api.

When manipulating shapes using vba code, how would I go about doing the following:

  • Change both the X and Y Scale factor on the shape (for example change both values from 100% to 103%)
  • Set the central position of the object to match the central position of another object
  • Alternatively to the above, set the position of an object based on the coordinates on the page (reference points confused me here. I tried shape.setposition but it never seemed to match up with what I wanted.)
  • Intersecting multiple objects separately at one time (for example take 3 pairs of objects, and intersect each pair at the same time, creating 3 intersected objects).

Any help would be greatly appreciated! I'm trying to learn this stuff quite fast for a job and Google isn't cooperating with me for some stuff! 

  • Cm1602 said:

    Hi guys, just thought I'd ask a few things here that I couldn't find on google or the help api.

    When manipulating shapes using vba code, how would I go about doing the following:

    • Change both the X and Y Scale factor on the shape (for example change both values from 100% to 103%)
    • Set the central position of the object to match the central position of another object
    • Alternatively to the above, set the position of an object based on the coordinates on the page (reference points confused me here. I tried shape.setposition but it never seemed to match up with what I wanted.)
    • Intersecting multiple objects separately at one time (for example take 3 pairs of objects, and intersect each pair at the same time, creating 3 intersected objects).

    Any help would be greatly appreciated! I'm trying to learn this stuff quite fast for a job and Google isn't cooperating with me for some stuff!

    I don't know if there is a way to directly access a "scale factor" for an object (and I would be happy to learn about it if there is), but shape.SizeHeight and .SizeWidth can be used to set height and width. With those, it's fairly simple to scale an object relative to its current size. If you want to figure out what the "original" - at creation - size of an object was, then I think it can get more involved.

    For center position of a shape, you might look as shape.CenterX and .CenterY.

    For reference points on a page, you might look at page.CenterX, .CenterY, .LeftX, .RightX, .TopY, .BottomY

    So, centering a shape on the active page might be:

    shape.CenterX = activepage.CenterX

    shape.CenterY = activepage.CenterY