none
PowerShell Word Image from URL RRS feed

  • Question

  • Is it possible to have PowerShell insert an image into a Word document from a URL instead of a local path? If so what is that syntax?

    As you can see below I reference an image file from my local computer. I'd like to be able to use the path of an image on our SharePoint server based upon it's URL so that I can turn this into a PS module and let anyone on my team be able to create the report and still get the logo.

    Thanks for any suggestions.

    cd "C:\scripts\DBA-SQL\Binn_Data_Permissions\WordReport"
    cls
    $endDate = (Get-Date).ToString("MM-dd-yyy_HHmmss")
    $Result = @()
    $OutputFileName = "c:\PowerShell\Results\SQL2005_Server_BINN-Data_Paths_" + $enddate + ".docx"
    $date = get-date
    $scriptpath = $MyInvocation.MyCommand.Path
    #$ScriptName = $MyInvocation.MyCommand.Name
    $notify = Get-QADUser $env:USERNAME | select firstname, lastname
    $firstName = $notify.FirstName
    $lastName = $notify.LastName
    $mycount = 0
    $usr = $env:username
    $word = new-object -ComObject word.application
    $Word.Visible = $True
    $Document = $Word.Documents.Add()
    $Selection = $Word.Selection
    
    $ObjShape = $Selection.inlineshapes.AddPicture("C:\Users\m0181he\Pictures\SQL_Dude.jpg")
    $objShape.HorizontalLineFormat
    $Selection.TypeParagraph()
    
    $Selection.Style = 'Title'
    $Selection.TypeText("SQL Server 2005 Audit Results")
    $Selection.TypeParagraph()
    $Selection.TypeText("File Processed: $($ScriptPath) `v")
    $Selection.TypeText("Report compiled on $(Get-Date) by $($firstName) $($lastName).`v")
    $Selection.TypeParagraph()
    


    • Moved by Bill_Stewart Friday, March 18, 2016 6:52 PM Move to more appropriate forum
    Wednesday, February 17, 2016 9:14 PM

Answers

  • No but you can display external content by using a link but it will have to be clicked.

    Embedded pictures must be downloaded first.


    \_(ツ)_/


    • Edited by jrv Wednesday, February 17, 2016 9:45 PM
    • Marked as answer by David_JunFeng Tuesday, March 29, 2016 1:30 AM
    Wednesday, February 17, 2016 9:41 PM

All replies

  • No but you can display external content by using a link but it will have to be clicked.

    Embedded pictures must be downloaded first.


    \_(ツ)_/


    • Edited by jrv Wednesday, February 17, 2016 9:45 PM
    • Marked as answer by David_JunFeng Tuesday, March 29, 2016 1:30 AM
    Wednesday, February 17, 2016 9:41 PM
  • Thank you for the confirmation. I can quit beating my head against the wall now.

    Regards,

    Marcus

    Wednesday, February 17, 2016 10:04 PM