Author Posts

April 13, 2016 at 1:54 am

Hello,

I would like to write on the same line, a word "bold", and the rest in "normal". How to do ? Because if I do not use "TypeParagraph", it keeps the same configuration (and I do not want a carriage return ...)

April 13, 2016 at 5:51 am

Sorry, I've no idea what you're talking about.

April 13, 2016 at 6:00 am

Hi Don Jones,

I actually insert text via powershell in a WORD file.

I have a phrase I have to insert which must include one and only in BOLD.

Herewith, the code I use:

$selection.TypeParagraph()
$selection.font.bold = 0
$selection.font.size = 10
$selection.font.name = "SFR Black"
$selection.typeText("SFR "+$PaysSite + " - ")

$selection.fond.name = "SFR Light"
$selection.font.bold = 0
$selection.font.size = 10
$selection.typeText($AdrSite)

$selection.font.bold = 0
$doc.Hyperlinks.Add($selection.Range,"$SiteUrl",'',"$SiteWeb","$SiteWeb")
$selection.typeText(" - ")
$doc.Hyperlinks.Add($selection.Range,"$SiteUrlB",'',"$SiteWebB","$SiteWebB")
$selection.TypeParagraph()

Nevertheless, the different [selection.font.Name = "Name of font"] does not work. If I do not use a [selection.TypeParagraph ()] to add a paragraph, the police remains the same.

Here is the result I would like to get:

[BOLD]SFR[BOLD] Text Text Text Text

([BOLD] just tell i want the word in bold)

Do you understand my demand ?
Sorry for my english ...

April 13, 2016 at 7:18 am

This is an example. It will bold the word 'random' in the string.

$string = 'random text text'
$sel.font.Bold = 1
If ($string -match 'random'){$sel.TypeText($Matches[0])}
$sel.font.Bold = 0
$sel.TypeText($string -replace 'random')

April 13, 2016 at 7:26 am

Random Commandline,

Sorry to ask you do that, but, can you show me a exemple with this :

$selection.TypeParagraph()
$selection.font.bold = 0
$selection.font.size = 10
$selection.font.name = "SFR Black"
$selection.typeText("SFR "+$PaysSite + " - ")

?

SFR text should be use font "SFR Black", but the rest (like $PaysSite) should use the fond "SFR Light" ...

Thank you !

April 13, 2016 at 7:43 am

Hi,

I do that :

$selection.TypeParagraph()
$selection.font.bold = 0
$selection.font.size = 10
$string = ("SFR "+$PaysSite+" - ")
$selection.font.name = "SFR Black"
If ($string -match 'SFR'){$selection.TypeText($Matches[0])}
$selection.TypeText($string -replace 'SFR')

But I have "SFR Belgium" (Belgium from $PaysSite) in "SFR Black" ... The rest is good but, why "Belgium" is too in "SFR Black" ?

Thank you !