How to replace text in header by logo, of word file

Rajagopalan Subramanian 0 Reputation points
2023-12-05T18:48:22.58+00:00

Hello All,

I have several word files and need to replace a text by logo (png or jpg). My word document has header. The header is a table and one column there is a text as 'logo'. I need to replace the logo by a picture. Can someone provide me a powershell code.

Thanks

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Client for IT Pros | User experience | Other
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Julio Cesar Leachi 1 Reputation point
    2023-12-05T19:34:34.8533333+00:00

    Na guia inserir, click em cabeçalho e escola a opção "Editar cabeçalho".
    Vá na guia INSERIR e escolha a imagem que deseja colocar no cabeçalho.
    Esta imagem pode ser editada a esquerda, centro, ou direita.


  2. Anonymous
    2023-12-06T07:28:46.09+00:00

    Hello,

    Please try the powershell script below to replace the header in the word file. I think it will works fine for the text replace text. If it not works for pictures, please let me know.

    $replaceWith = "New Text !"
    $replace = [Microsoft.Office.Interop.Word.WdReplace]::wdReplaceAll
    $findWrap = [Microsoft.Office.Interop.Word.WdFindWrap]::wdFindContinue
    
    $find = $header.Range.find
    $find.Execute($header.Range.Text, 
                  $false, #match case
                  $false, #match whole word
                  $false, #match wildcards
                  $false, #match soundslike
                  $false, #match all word forms
                  $true,  #forward
                  $findWrap, 
                  $null,      #format
                  $replaceWith,
                  $replace)
    

    Best Regards,

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.