|
1 | | -Clear-Host |
2 | | -#Import-Module .\PSWriteOffice.psd1 -Force |
| 1 | +Import-Module (Join-Path $PSScriptRoot '..\PSWriteOffice.psd1') -Force |
3 | 2 |
|
4 | | -$Presentation = New-OfficePowerPoint -FilePath "$PSScriptRoot\Documents\ExamplePowerPoint1.pptx" |
| 3 | +$documents = Join-Path $PSScriptRoot 'Documents' |
| 4 | +New-Item -Path $documents -ItemType Directory -Force | Out-Null |
5 | 5 |
|
6 | | -Add-OfficePowerPointSlide -Presentation $Presentation -Layout 1 |
| 6 | +$path = Join-Path $documents 'ExamplePowerPoint1.pptx' |
| 7 | +$presentation = New-OfficePowerPoint -FilePath $path |
7 | 8 |
|
8 | | -Write-Host $Presentation.Slides.Count -ForegroundColor Green |
| 9 | +$slide1 = Add-OfficePowerPointSlide -Presentation $presentation -Layout 1 |
| 10 | +Set-OfficePowerPointSlideTitle -Slide $slide1 -Title 'Status Update' | Out-Null |
| 11 | +Add-OfficePowerPointTextBox -Slide $slide1 -Text 'Generated with PSWriteOffice' -X 80 -Y 150 -Width 320 -Height 40 | Out-Null |
| 12 | +Add-OfficePowerPointShape -Slide $slide1 -ShapeType Rectangle -X 80 -Y 210 -Width 320 -Height 120 -FillColor '#DDEEFF' -OutlineColor '#4472C4' -OutlineWidth 1 | Out-Null |
9 | 13 |
|
10 | | -# Get the shapes collection from the first slide |
11 | | -$shapes = $Presentation.Slides[0].Shapes |
| 14 | +$slide2 = Add-OfficePowerPointSlide -Presentation $presentation -Layout 1 |
| 15 | +Set-OfficePowerPointSlideTitle -Slide $slide2 -Title 'Next Steps' | Out-Null |
| 16 | +Add-OfficePowerPointTextBox -Slide $slide2 -Text '1. Review numbers 2. Plan Q1 3. Ship' -X 80 -Y 150 -Width 360 -Height 80 | Out-Null |
12 | 17 |
|
13 | | -# Add a new rectangle shape |
14 | | -$shapes.AddRectangle(50, 60, 100, 70) |
15 | | - |
16 | | -$shapes.Item(0).TextBox.Text = "Hello World!" |
17 | | - |
18 | | -$Presentation.Slides[1].Shapes | Format-Table |
19 | | - |
20 | | -$Presentation.Slides[1].Shapes[0].TextBox.Text = "This is my title" |
21 | | - |
22 | | -Save-OfficePowerPoint -Presentation $Presentation -Show |
| 18 | +Save-OfficePowerPoint -Presentation $presentation |
| 19 | +Write-Host "Presentation saved to $path" |
0 commit comments