简体   繁体   English

VBA Excel -> 在页码下方添加图片

[英]VBA Excel -> Add picture below page number

I have a little picture that I would like to add into my word document, with Excel VBA.我有一张小图片,我想用 Excel VBA 添加到我的 Word 文档中。 The thing is that it is not a problem to add it to the footers.问题是将它添加到页脚不是问题。 But I would like to add it below the page number which i illustrated in the picture.但是我想将它添加到我在图片中说明的页码下方。

在此处输入图片说明

I have tried many things and used google to find inspiration.我尝试了很多东西并使用谷歌寻找灵感。 However, I cannot find any solution which solves this kind of problem.但是,我找不到任何解决此类问题的解决方案。 Do anyone have an idea to solve this?有没有人有解决这个问题的想法?

Set B2 = ActiveSheet.Shapes("P2")设置 B2 = ActiveSheet.Shapes("P2")

With wApp
    .Visible = True
    .Activate
    Set wdDoc = .Documents.Add()
    With wdDoc
        With wApp.ActiveDocument.PageSetup
            .TopMargin = CentimetersToPoints(2.5)
            .LeftMargin = CentimetersToPoints(2)
            .RightMargin = CentimetersToPoints(4.7)
            .BottomMargin = CentimetersToPoints(2.5)
            .HeaderDistance = CentimetersToPoints(0.98)
            .FooterDistance = CentimetersToPoints(1.5)
        End With
        B2.Copy
        With .Sections(1).Footers(wdHeaderFooterPrimary).Range
            .Font.Size = 7
            .Font.Name = "Arial"
            With .ParagraphFormat
                .Alignment = wdAlignParagraphLeft
                .TabStops.Add Position:=InchesToPoints(7), Alignment:=wdAlignTabRight
            End With
            .InsertAfter "THIS IS THE COMPANY IN THE LFT PART OF FOOTERS" & vbTab & "Page "
            .Fields.Add Range:=.Characters.Last, Type:=wdFieldEmpty, Text:="PAGE", PreserveFormatting:=False
            .InsertAfter Text:=" / "
            .Fields.Add Range:=.Characters.Last, Type:=wdFieldEmpty, Text:="NUMPAGES", PreserveFormatting:=False
            .InsertAfter Chr(11) & vbTab
            .Collapse wdCollapseEnd
            .Paste
            .End = .End + 1
            With .InlineShapes(1)
                .LockAspectRatio = True
                .Height = InchesToPoints(0.25)
            End With

Kind regards亲切的问候

Mathias马蒂亚斯

Perhaps:也许:

With .Sections(1).Footers(wdHeaderFooterPrimary).Range
    .Font.Size = 7
    .Font.Name = "Arial"
    With .ParagraphFormat
      .Alignment = wdAlignParagraphLeft
      .TabStops.Add Position:=InchesToPoints(7), Alignment:=wdAlignTabRight
    End With
    .InsertAfter "THIS IS THE COMPANY IN THE LFT PART OF FOOTERS" & vbTab & "Page "
    .Fields.Add Range:=.Characters.Last, Type:=wdFieldEmpty, Text:="PAGE", PreserveFormatting:=False
    .InsertAfter Text:=" / "
    .Fields.Add Range:=.Characters.Last, Type:=wdFieldEmpty, Text:="NUMPAGES", PreserveFormatting:=False
    .InsertAfter Chr(11) & vbTab
    .Characters.Last.Paste
    .End = .End + 1
    With .InlineShapes(1)
      .LockAspectRatio = True
      .Height = InchesToPoints(0.25)
    End With
End With

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM