Skip to content

Instantly share code, notes, and snippets.

@eugrus
Last active November 25, 2024 15:49
Show Gist options
  • Save eugrus/d92417a6e256b244e9c7adde0817d63f to your computer and use it in GitHub Desktop.
Save eugrus/d92417a6e256b244e9c7adde0817d63f to your computer and use it in GitHub Desktop.
Rubrum eines anwaltlichen Schreibens auslesen
function Rubrumauslese () {
$wordApp = [Runtime.Interopservices.Marshal]::GetActiveObject('Word.Application')
$doc = $wordApp.ActiveDocument
$documentText = $doc.Content.Text -replace '\r',[System.Environment]::Newline
$Az = [regex]::match($documentText, '\d{1,5}/\d{2}').Value
$Mandant, $Gegner = ((Select-String -InputObject $documentText -Pattern '.*\./\..*').matches.value -split './.').trim()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($wordApp) | Out-Null
return [PSCustomObject]@{
Mandant = $Mandant
Gegner = $Gegner
Az = $Az
}
}
$Rubrum = Rubrumauslese
$Az = $Rubrum.Az
$Mandant = $Rubrum.Mandant
$Gegner = $Rubrum.Gegner
Write-Output "$Mandant"
Write-Output "./."
Write-Output "$Gegner"
Write-Output "$Az"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment