PoshCode Archive  Artifact [068fe1871c]

Artifact 068fe1871c696c2a7ffea44f82380ce9e231282b568cff86f41959a4219bfea6:

  • File Pipe-Clipboard-to-Word.ps1 — part of check-in [879d9e4eee] at 2018-06-10 14:19:42 on branch trunk — Quick, dirty, and ugly way to output clipboard data to Microsoft Word. (user: Banker42 size: 1025)

# encoding: ascii
# api: powershell
# title: Pipe Clipboard to Word
# description: Quick, dirty, and ugly way to output clipboard data to Microsoft Word.
# version: 12.0
# type: function
# author: Banker42
# license: CC0
# x-poshcode-id: 6708
# x-archived: 2017-05-11T14:50:12
# x-published: 2017-01-20T20:10:00
#
#
<#Examples

.Get-Hotfix | clip.exe | AutoWord

.Get-Hotfix | Format-List | clip.exe | AutoWord

#>


Function Paste {

Add-Type -AssemblyName System.Windows.Forms
$P = New-Object System.Windows.Forms.TextBox
$P.Multiline = $true
$P.Paste()
$P.Text

}

Function AutoWord {

param ([string[]]$Paste)

$Word = New-Object -ComObject Word.Application
$Word.visible = $true

if (($WordVersion -eq "12.0") -or ($WordVersion -eq "11.0"))
    {    
    $Word.DisplayAlerts = $false
    }
    else
    {
    $Word.DisplayAlerts = "wdAlertsNone"
    }

$Paste = Paste
$Document = $Word.Documents.Add()
$Selection = $Word.Selection
$Selection.TypeText("$Paste")


}