scripting - Special Characters in Powershell -
i trying work powershell , have output copyright character ms word document. example, code listed below trying use , not working.
$summarypara.range.text = "© " $summarypara.range.text = "get-date -format yyyy" $summarypara.range.text = " - name of org here " $summarypara.range.insertparagraphafter() do need use alt+0169 sequence somehow? not sure doing wrong since following code seems work:
$selection.typeparagraph() $selection.typetext("© ") $selection.typetext((get-date -format yyyy)) $selection.typetext(" - name of org here ") $selection.typeparagraph() any appreciate making work both copyright character , other similar special characters.
there few problems here. i'll list , address each:
1) can character need casting unicode representation char. in case
[char]0x00a9 2) assign new value $summarypara.range.text 3 times. so, overwriting previous value each time, instead of concatenating ('+' operator), think trying do.
3) trying use cmdlet get-date, since have quoted it, end literal string "get-date -format yyyy", instead of result of cmdlet.
putting together, think want this:
$word = new-object -comobject word.application $doc = $word.documents.add() $summarypara = $doc.content.paragraphs.add() $summarypara.range.text = [char]0x00a9 + ($date = get-date -format yyyy) + " - name of org here " $word.visible = $true hope helps. luck.
Comments
Post a Comment