我复制Excel工作表的不同区域,并将其作为图像粘贴到电子邮件正文中。
我想将这些图像粘贴到电子邮件的中心位置。
Sub SendEmail()
Dim olApp As Outlook.Application
Dim olEmail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Word.Document
Dim strGreeting As String
strGreeting = "Dear Someone," & vbNewLine
Set olApp = New Outlook.Application
Set olEmail = olApp.CreateItem(olMailItem)
With olEmail
.BodyFormat = olFormatRichText
.Display
.To = "Someone@tester.com"
.Subject = "Report"
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
wdDoc.Range.InsertBefore strGreeting
wdDoc.Range.InsertAfter vbCrLf
Range("B1:O56").Copy
PasteAtEnd wdDoc
wdDoc.Range.InsertAfter vbCrLf
Range("B57:O111").Copy
PasteAtEnd wdDoc
wdDoc.Range.InsertAfter vbCrLf
Range("B112:O172").Copy
PasteAtEnd wdDoc
End With
End Sub
'paste from clipboard to the end of the document
Sub PasteAtEnd(doc As Word.Document)
With doc
.Content.Select
.Application.Selection.Collapse (wdCollapseEnd)
.Application.Selection.PasteAndFormat wdChartPicture
End With
End Sub
2条答案
按热度按时间kzipqqlq1#
在Word中,您可以
center-align
个段落。例如:ruarlubt2#
我可以使用下面的代码将所有图像和问候居中:
设置wdRange = wdDoc.范围(0,wdDoc.字符数)
谢谢!