我想使用VBA对从excel范围选择发送的电子邮件进行居中对齐,但我不确定将其放在代码中的哪个位置。有人建议我只在我的范围中添加一列。无论如何我可以把代码放在VBA中。顺便说一句,我真的很擅长这种语言(比如一小时前)。这是我的代码,我是从微软页面获得的:
Sub Send_Range()
ActiveSheet.Range("D4:L23").Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = "ABZ@123.com"
.Item.Subject = "REMINDER: HELLO TEST" & " " & Format(Now, "mmmm yyyy")
.Item.Send
End With
End Sub
答案 0 :(得分:2)
Scott所指的简单版本将是
Sub test()
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
sEmail = "Please check your status on " & Activesheet.Range("A1").value
'ie..Range("A1").value has the formula "=today()"
With OutMail
.to = ""
.CC = ""
.BCC = ""
'.FROM = ""
.Subject = ""
.htmlBody = "<p align=""center"">" & sEmail & "</p>"
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub