Share via

Powerpoint Interop C# Paste Keep Source Formatting

Anonymous
2015-12-29T11:32:07+00:00

Hi,

I am using PowerPoint Interop (C# language) to copy Excel content to PowerPoint. 

var resultRange = templateExcelWorksheet.UsedRange;

resultRange.Copy();

pptSlide.Shapes.Paste();

I want to keep Source Formatting (i.e. Excel format) in PowerPoint Slide as well. How can I do it through program in C#.

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

Answer accepted by question author

Anonymous
2015-12-29T21:28:46+00:00

Have you tried using:

Globals.ThisAddIn.Application.CommandBars.ExecuteMso("PasteSourceFormatting");instead of:pptSlide.Shapes.Paste();

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-12-30T15:22:20+00:00

    Don't use the clipboard then. Use the AddOLEObject method but this requires that the file  being embedded be present on disk.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-12-30T06:12:44+00:00

    Have you tried using:

    Globals.ThisAddIn.Application.CommandBars.ExecuteMso("PasteSourceFormatting");instead of:pptSlide.Shapes.Paste();
    

    I tried

    pptApp.CommandBars.ExecuteMso("PasteSourceFormatting"); 

    and it worked.

    But only if PowerPoint is visible in window; open presentation with Window.

    presentation = pptApp.Presentations.Open(reportFilePath, WithWindow: Microsoft.Office.Core.MsoTriState.msoTrue);

    Is there a way, I can keep PowerPoint invisible and still perform similar action.

    Was this answer helpful?

    0 comments No comments