Simple question TypeText

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Florian Schinas Florian Schinas 8 months ago.

  • Author
    Posts
  • #37633
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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 ...)

  • #37647
    Profile photo of Don Jones
    Don Jones
    Keymaster

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

  • #37650
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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 ...

  • #37667
    Profile photo of random commandline
    random commandline
    Participant

    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')
    
  • #37670
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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 !

  • #37672
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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 !

  • #37720
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    Hi,

    Resolve !

You must be logged in to reply to this topic.