vb操作word页眉设置


   With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
       Set rng = .Range
       rng.Font.Name = "仿宋"
       rng.Font.Size = 10 '
       rng.Text = "监察部 "
       .Range.Fields.Update
       .Range.ParagraphFormat.Alignment = wdAlignParagraphRight
   End With

请问我想在页眉的左边加上LOGO,怎么添加代码

liu_xx110菩薩慈悲:看這樣合不合用?


Sub Logo_added_to_the_top_left_of_the_page()
    Dim rng As Range, ur As UndoRecord, logo As InlineShape, sp As Shape
    Set ur = Word.Application.UndoRecord
       '開始記錄本程序的還原步驟,如此在執行程序完後,只要按一下還原鈕或Ctrl+z,即可還原到文檔之原樣
    ur.StartCustomRecord "Logo_added_to_the_top_left_of_the_page"
   With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
       Set rng = .Range
       rng.Font.Name = "fangsong"
       rng.Font.Size = 10
       rng.Text = "監察部"
       .Range.Fields.Update
       '讓要插人的LOGO圖檔置中
       .Range.ParagraphFormat.BaseLineAlignment = wdBaselineAlignCenter
       '插入圖檔
        Set logo = rng.InlineShapes.AddPicture("C:\Users\SSZ3\Pictures\yourLOGO.png"
       '將插入的與文字排列的圖檔改成文繞圖型,以免與文字排列
        Set sp = logo.ConvertToShape
       '此時才執行文字的向右對齊,自然與文繞圖各據頁首之一方了。
        .Range.ParagraphFormat.Alignment = wdAlignParagraphRight
   End With
       '記錄此次還原步驟截止
   ur.EndCustomRecord
End Sub

感恩感恩 讚歎讚歎 南無阿彌陀佛