Last active
June 13, 2023 08:11
-
-
Save Fabaderheld/63fdd472c35d71d58f6214384cf6955f to your computer and use it in GitHub Desktop.
Work with Word documents in Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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