Reputation: 217
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?
Upvotes: 1
Views: 390
Reputation: 144
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.
Upvotes: 1