Share via

Programmatically Copy Shapes with source formatting (PowerPoint 2007)

Anonymous
2010-11-08T16:27:48+00:00

I need to be able to copy shapes (chart, table, etc.) programmatically from one slide to another in PowerPoint 2007 keeping their original colors. The source and destination slides are in different presentations which have different themes.

These shapes might be complex and include a lot of colors, e.g., charts, tables, etc. The destination slide must maintain its theme, so I cannot simply copy the entire original slide colorScheme.

When copying a shape manually in Powerpoint, I get an option to "Keep Source Formatting". This copies all the original colors of the shape, converting theme colors into absolute RGB values.

What is the simplest way to do this programmatically?

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Steve Rindsberg 99,161 Reputation points MVP Volunteer Moderator
    2010-11-11T02:33:34+00:00

    A lot, though not all, of the tedious format copying can be done with:

    OriginalShape.PickUp

    DuplicateShape.Apply

    (This is the VBA equivalent of using the format painter)


    Steve Rindsberg PowerPoint MVP

    PowerPoint FAQ

    PPTools Add-ins for PowerPoint

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2010-11-10T12:39:28+00:00

    There isn't a one size fits all answer for this, as the coding will be different in order to correctly copy all of the formatting from the original shape. From where I sit, you probably need to first copy the shape over, and then go through the FillFormat methods and match the copied shape to the original manually. Matching RGB values is fairly simple, but matching gradient settings and other advanced options is a little more difficult. This becomes even more sticky if you are importing from Excel. I don't work with graphs and tables that often, so I can't offer any example code. I did see some examples in the Object Model Reference under FillFormat for matching Gradient Fill settings between shapes, so that might be a place to start.

    In the end you're probably going to have to manually reference the values from the original shape and match them to your newly copied shape. I could be wrong though, so don't take this as the final answer.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-11-09T15:45:41+00:00

    Thanks for the idea.

    However, I do need the target object to be the same as the original, i.e., "Live" and not a picture.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-11-08T20:04:48+00:00

    I need to be able to copy shapes (chart, table, etc.) programmatically from one slide to another in PowerPoint 2007 keeping their original colors. The source and destination slides are in different presentations which have different themes.

    These shapes might be complex and include a lot of colors, e.g., charts, tables, etc. The destination slide must maintain its theme, so I cannot simply copy the entire original slide colorScheme.

    When copying a shape manually in Powerpoint, I get an option to "Keep Source Formatting". This copies all the original colors of the shape, converting theme colors into absolute RGB values.

    What is the simplest way to do this programmatically?

    IF you don't need to paste as live objects you can use

    ActivePresentation.Slides(1).Shapes.PasteSpecial(ppPasteEnhancedMetafile)

    which will paste as EMF with original colorTheme


    Best regards, Harvey

    Was this answer helpful?

    0 comments No comments