如何从Excel VBA对齐中心发送的电子邮件 [英] How to align center sent email from excel VBA

查看:140
本文介绍了如何从Excel VBA对齐中心发送的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用VBA对从excel范围选择中发送的电子邮件进行居中对齐,但是我不确定将其放在代码中的哪个位置.有人建议我在范围内添加一列.无论如何,我可以将代码放入VBA中.顺便说一句,我真的是这种语言的新手(就像一个小时前一样).这是我的代码,我是从Microsoft页面获得的:

I want to center-align an email I sent from excel range selection using VBA but I'm not sure where to put it in the code. Someone suggested me to just add a column to my range. Is there anyway I can put the code in VBA. Btw, I'm really new at this language (like just an hour ago). Here's my code, I got it from a microsoft page:

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

成品:

推荐答案

Scott所指的简单版本是

A simple version of what Scott is referring to would be

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

这篇关于如何从Excel VBA对齐中心发送的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆