1

I am trying to paste several excel tables into powerpoint using Powershell:

$shape = $slide.Shapes.PasteSpecial($ppPasteJPG,$false,$null,$null,$null,$null)

It seems to work perfectly with two of the 6 excel tables I am pasting, but with the other 4 it does not. The two it works with are .xlsm, whereas the 6 are xlsx. Why is this, and how can I make it work with all of them? How can I paste the selected ranges from the xlsx files into PowerPoint such that they are formatted as they are in excel?

1 Answer 1

1

You can paste while keeping source formatting by using the CommandBars.ExecuteMso from either the presentation object or the application object. The command string is "PasteSourceFormatting" so after you've activated the Cell you're trying to insert the table into, run the command:

$pptApplication.CommandBars.ExecuteMso("PasteSourceFormatting");

After you've done that, use Shapes to find the newly inserted table to modify placement, size, etc.

Sign up to request clarification or add additional context in comments.

1 Comment

Also, apparently adding sleep statements if helpful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.