Skip to content

Instantly share code, notes, and snippets.

@Fabaderheld
Last active June 13, 2023 08:11
Show Gist options
  • Save Fabaderheld/63fdd472c35d71d58f6214384cf6955f to your computer and use it in GitHub Desktop.
Save Fabaderheld/63fdd472c35d71d58f6214384cf6955f to your computer and use it in GitHub Desktop.
Work with Word documents in Powershell
Add-Type -Path "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Word.dll" # Load Word Interop assembly
$Word = New-Object -ComObject Word.Application # Create new Word object
# Get Active Document
$doc = $word.ActiveDocument # Get active document
# Add Logo
$logoPath = "C:\temp\stv\stv-04.png" # Path to logo
$logoShape = $doc.Shapes.AddPicture($logoPath, $false, $true).ConvertToInlineShape() # Add logo
$logoShape.LockAspectRatio = $true # Lock aspect ratio
$logoShape.Width = 50 # Adjust the logo width as needed
$logoShape.Height = 50 # Adjust the logo height as needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment