如何将 excel 中的内容放在 Outlook 签名上方

How to place content from excel above outlook signature

提问人:Jovi 提问时间:11/8/2023 最后编辑:Jovi 更新时间:11/8/2023 访问量:51

问:

我正在尝试通过VBA将excel内容自动化到outlook中 但是,excel内容一直出现在我的Outlook签名下方

如何修改我的代码,以便 excel 内容在我的签名之前显示?提前谢谢大家

以下是我的代码:

Private Sub CommandButton1_Click()

Dim outlookapp As Outlook.Application
Dim outlookmail As Outlook.MailItem
Dim outlookins As Outlook.Inspector

Dim OlWordDoc As Word.Document
Dim OlWordRng As Word.Range

Dim ExcelRng As Range

Set outlookapp = New Outlook.Application
Set outlookmail = outlookapp.CreateItem(olMailItem)

Set ExcelRng = Sheet5.Range("A3:C6")

 With outlookmail

    .BodyFormat = olFormatHTML
    .Display
    
    .To = "[email protected]"
    .Subject = "Commodity Allocation"
    .HTMLBody = "Below are the allocations" & .HTMLBody
    
    'Get the Active Inspector
    Set outlookins = .GetInspector
    
    'Get the Word Editor
    Set OlWordDoc = outlookins.WordEditor
    
    
    'Specify the Range in the Document
    Set OlWordRng = OlWordDoc.Application.ActiveDocument.Content
        OlWordRng.Collapse Direction:=wdCollapseEnd
        
    'Insert a page break
        OlWordRng.InsertParagraph
        OlWordRng.InsertBreak
        
    'Copy the Excel Range
    ExcelRng.Copy
    
    'Paste into Word document
    OlWordRng.PasteSpecial DataType:=wdPasteHTML

 End With

End Sub
Excel VBA 电子邮件 Outlook

评论

0赞 CDP1802 11/8/2023
原则上,用 after 存储签名,用 wordeditor 在末尾添加回来。这里的例子signature = .body.Display

答: 暂无答案