Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell将excel表格粘贴到powerpoint中,同时保留格式_Excel_Powershell_Powerpoint - Fatal编程技术网

如何使用Powershell将excel表格粘贴到powerpoint中,同时保留格式

如何使用Powershell将excel表格粘贴到powerpoint中,同时保留格式,excel,powershell,powerpoint,Excel,Powershell,Powerpoint,我正在尝试使用Powershell将几个excel表格粘贴到powerpoint中: $shape = $slide.Shapes.PasteSpecial($ppPasteJPG,$false,$null,$null,$null,$null) 在我粘贴的6个excel表格中,有两个似乎可以很好地使用它,但在其他4个表格中却不能。它使用的两个是.xlsm,而6个是xlsx。为什么会这样,我如何才能让它与所有人一起工作?如何将xlsx文件中的选定范围粘贴到PowerPoint中,使其格式与exc

我正在尝试使用Powershell将几个excel表格粘贴到powerpoint中:

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

在我粘贴的6个excel表格中,有两个似乎可以很好地使用它,但在其他4个表格中却不能。它使用的两个是.xlsm,而6个是xlsx。为什么会这样,我如何才能让它与所有人一起工作?如何将xlsx文件中的选定范围粘贴到PowerPoint中,使其格式与excel中的格式相同

您可以从presentation对象或application对象使用CommandBars.ExecuteMso在保留源格式的同时进行粘贴。命令字符串为“PasteSourceFormatting”,因此在激活要插入表格的单元格后,请运行以下命令:

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

完成后,使用形状查找新插入的表,以修改位置、大小等。

此外,如果有帮助,显然还可以添加睡眠语句