Home > Net >  Open PowerPoint and then SaveAs
Open PowerPoint and then SaveAs

Time:12-04

I am not programmer and I need help. I would like to script my daily task.

  • Open PowerPoint (.pptx format) - DONE
  • Press 'A' button to update numbers from Excel - DONE
  • Save PowerPoint (.pptx format) - Do not know how to do it
  • And then save PowerPoint again in .ppsx format and Close it - Do not know how to do it

How to do it please? I tried to create .ps1 script, but do not know how to continue.

There is my code:

Start-Process -FilePath "\\192.168.1.2\I\IT\Public\TV\NM\PrezentaceNM.pptx"

Start-Sleep -s 15

$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys('A')

Start-Sleep -s 45

CodePudding user response:

to open PowerPoint files using script can be found here -

Presentations.Open method (PowerPoint)

https://docs.microsoft.com/en-us/office/vba/api/PowerPoint.Presentations.Open

PowerShell Script to open Powerpoint and play a slide show

Powershell scipt to open power point and play slide show

To Open & Close PowerPoint Using PowerShell

##File Path
$PowerpointFile = ""\\192.168.1.2\I\IT\Public\TV\NM\PrezentaceNM.pptx""
##Create Com Object
$Powerpoint = New-Object -ComObject powerpoint.application
$ppt = $Powerpoint.presentations.open($PowerpointFile, $True, $False)

$ppt.  ##Do Stuff

Sleep -Seconds 3
$ppt.Save()
$Powerpoint.Quit()

CodePudding user response:

I moved little bit forward. Now I need to know how to add SaveAs and save it as ppsx. Any Idea? Current code:

Start-Process -FilePath "\\192.168.1.2\I\IT\Public\TV\NM\PrezentaceNM.pptx"

Start-Sleep -s 15

$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys('A')

Start-Sleep -s 40

$wshell.SendKeys('^(s)')

Start-Sleep -s 15

Stop-Process -Name POWERPNT
  • Related