0

I'm currently trying to create a calendar in powerpoint using powershell. All I want to do is insert a table into a powerpoint slide. This table is representing the month of January, it contains the days of the week etc.

I did some research and came across this.

This is VB script, so i tried to "create its equivalent" in powershell:

EDIT3: I was finally able to copy my table from Excel and paste it into my powerpoint slide using this code:

#Create an instance of Excel.
$xl=New-Object -ComObject "Excel.Application"
$xl.Visible = $True

#Open the Excel file containing the table. 
$wb = $xl.workbooks.open("C:\January.xls")
$ws = $wb.ActiveSheet

#Select the table.
$range = $ws.range("A1:G7")
$range.select()

#Copy the table to the clipboard.
$range.copyPicture()

#Create an instance of Powerpoint.
$objPPT = New-Object -ComObject "Powerpoint.Application"
$objPPT.Visible ='Msotrue'

#Add a slide to the presentation.    
$project = $objPPT.Presentations.Add()
$slide  = $project.Slides.Add(1, 1)

#Paste the table into the slide.
$shape = $slide.Shapes.Paste()

#Position the table.
$shape.Left = 50
$shape.Top = 150
$shape.Width = 300
$shape.Height = 168

Thanks to those who have helped me here and on #powershell

4

2 回答 2

0

I think you can use this:

# Optionally, make sure you're on the last slide:
$ppt.ActiveWindow.View.GotoSlide( $ppt.ActivePresentation.Slides.Count )

# Specify the 
$ppt.ActiveWindow.View.PasteSpecial( "ppPasteOLEObject", "msoFalse",  "", 0, "", "msoFalse")

See the MSDN Interop Docs and thanks to this example: Paste Excel Chart into Powerpoint using VBA

于 2013-10-26T05:59:52.110 回答
0

I saw your question in the channel. This worked for me:

$presentation = $ppt.Presentations.Open($ifile)
$sl = $presentation.Slides.Add(1, $ppLayoutBlank) 
$shape = $sl.shapes.paste()
于 2013-10-27T10:44:53.140 回答