-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd30d63
commit 100fc4e
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This is just a show what can be quickly done using .NET before I get to do it's PowerShell version | ||
|
||
Clear-Host | ||
Import-Module .\PSWriteOffice.psd1 -Force | ||
|
||
$Document = New-OfficeWord -FilePath $PSScriptRoot\Documents\BasicDocumentWithSomeText.docx | ||
$Document.BuiltinDocumentProperties.Title = "This is title" | ||
$Document.BuiltinDocumentProperties.Subject = "This is subject aka subtitle" | ||
|
||
New-OfficeWordText -Document $Document -Text 'This is a test 1 ', 'and this should be bold' -Bold $null, $true -Underline Dash, $null | ||
|
||
New-OfficeWordText -Document $Document -Text 'This is a test 2', ' and we continue using different color' -Color Blue, Gold -Alignment Right | ||
New-OfficeWordText -Document $Document -Text 'This is a test 3 ', 'and this should be bold' -Bold $null, $true -Underline Dash, $null | ||
|
||
New-OfficeWordText -Document $Document -Text 'This is a test 4', ' something else' -Color Green, Gold -Alignment Right | ||
New-OfficeWordText -Document $Document -Text 'This is a test 5 ', 'and this should be bold' -Bold $null, $true -Underline Dash, $null | ||
|
||
New-OfficeWordText -Document $Document -Text 'This is a test 6', ' even more text' -Color Blue, Gold -Alignment Right | ||
|
||
foreach ($Paragraph in $Document.Paragraphs) { | ||
if ($Paragraph.Text) { | ||
if ($Paragraph.Text -like "*test 4*") { | ||
$Paragraph.Text = "We replace that value, but we keep the same color" | ||
} | ||
} | ||
} | ||
|
||
Save-OfficeWord -Document $Document -Show |