Open v-bulynkin opened 1 year ago
$Document = New-OfficeWord -FilePath $PSScriptRoot\Documents\BasicDocument.docx
$Document.Settings.FontFamily = 'Times New Roman'
New-OfficeWordText -Document $Document -Text 'This is a test, very big test ', 'and this should be bold' -Bold $null, $true -Underline Dash, $null
New-OfficeWordText -Document $Document -Text 'This is a test, very big test', 'ooops' -Color Blue, Gold -Alignment Right
$Paragraph = New-OfficeWordText -Document $Document -Text 'Centered' -Color Blue, Gold -Alignment Center -ReturnObject
New-OfficeWordText -Document $Document -Text ' Attached to existing paragraph', ' continue' -Paragraph $Paragraph -Color Blue
$Paragraph.FontFamily = 'Arial'
Save-OfficeWord -Document $Document -Show
Works for me?
It works only with English characters
$docFile = "C:\temp\doc.docx"
rm $docFile
$doc = New-OfficeWord -FilePath $docFile
$doc.Settings.FontFamily = 'Times New Roman'
$doc.Settings.FontSize = 11
$p1 = New-OfficeWordText -Document $doc -Bold $true -Alignment Center -Text `
'Абвг' -ReturnObject
$p1.AddBreak()
New-OfficeWordText -Document $doc -Bold $true -Paragraph $p1 -Text `
"Abcd"
Save-OfficeWord -Document $doc -Show
Then use FontFamilyHighAnsi
$Document.Settings.FontFamily = 'Times New Roman'
$Document.Settings.FontFamilyHighAnsi = 'Times New Roman'
I think we don't set HighAnsi for paragraph directly which may need fixing in OfficeIMO.
FontFamilyHighAnsi works, thank you. But there is an interesting thing - spaces, numbers and everything except letters are resistant to font changing.
Default font is Arial, so I have <Word (Times New Roman)><Space (Arial)><Word (Times New Roman)><Space (Arial)><Word (Times New Roman)> etc.
Upd: sorry, the options FontFamilyHighAnsi and FontFamily must be used simultaneously.
I will change the logic in OfficeIMO and PSWriteOffice and change the logic:
Same for Paragraph FontFamily will set both, and FontFamilyHighAnsi will just set HighAnsi. I believe this is the most common use case where both entries are the same for majority of the people and only in certain languages it will be different so they will have to ensure they run things in proper order.
How to set font of document or paragraph?
I could change font size:
However, I can't set the font itself. The settings below don't work: