I have a VBA script that that generates and email when a VBA button is pushed in a given worksheet.
我有一个VBA脚本,当在给定的工作表中按下VBA按钮时,该脚本会生成并发送电子邮件。
The script currently generates the email in a relatively small font. I was wondering if there is a way to set the font to Calibri, and the text sive to exactly 11.
该脚本当前以相对较小的字体生成电子邮件。我想知道是否有一种方法可以将字体设置为Calibri,文本正好适用于11。
Here is the current VBA script:
这是当前的VBA脚本:
Private Sub CommandButton1_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim strUser As String
Dim signature As String
Dim sTo As String
Dim sCC As String
'For To field
Set emailRng = Worksheets("Send Email").Range("D3:I6")
For Each cl In emailRng
sTo = sTo & ";" & cl.Value
Next
sTo = Mid(sTo, 2)
'For CC field
Set emailRngCC = Worksheets("Send Email").Range("D8:I11")
For Each cl In emailRngCC
sCC = sCC & ";" & cl.Value
Next
sCC = Mid(sCC, 2)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Display
End With
signature = OutMail.HTMLBody
strbody = "<FONT SIZE = 3>Good Morning;<p>We have completed our main aliasing process for today. All assigned firms are complete. Please feel free to respond with any questions.<p>Thank you."
With OutMail
.SentOnBehalfOfName = ""
.To = sTo
.CC = sCC
.BCC = ""
.Subject = "Data Morning Alias Process - COMPLETE"
.HTMLBody = strbody & signature
.Display
End With
End Sub
I know that this portion of the code:
我知道这部分代码:
strbody = "<FONT SIZE = 3.5>Good Morning;<p>We have completed our main aliasing
is the portion that relates to the email body text size. But a setting of 3 is to small, and a setting of 4 is too big. So I was just wondering if there is some way I can set the font to be exactly size 11, and the text to be formatted as Calibri?
是与电子邮件正文文本大小相关的部分。但是3的设置是小的,4的设置太大。所以我只是想知道是否有某种方法我可以将字体设置为11格式,并将文本格式化为Calibri?
Thank you!
谢谢!
2 个解决方案
#1
13
I did a little research and was able to write this code:
我做了一点研究,并且能够编写这段代码:
strbody = "<BODY style=font-size:11pt;font-family:Calibri>Good Morning;<p>We have completed our main aliasing process for today. All assigned firms are complete. Please feel free to respond with any questions.<p>Thank you.</BODY>"
apparently by setting the "font-size=11pt"
instead of setting the font size <font size=5>
, It allows you to select a specific font size like you normally would in a text editor, as opposed to selecting a value from 1-7 like my code was originally.
显然通过设置“font-size = 11pt”而不是设置字体大小,它允许您选择特定的字体大小,就像在文本编辑器中一样,而不是从1中选择一个值。 -7就像我原来的代码一样。
This link from simpLE MAn gave me some good info.
来自simpLE MAn的这个链接给了我一些很好的信息。
#2
0
FYI I did a little research as well and if the name of the font-family you want to apply contains spaces (as an example I take Gill Alt One MT Light), you should write it this way :
仅供参考我也进行了一些研究,如果你要应用的font-family的名称包含空格(例如我采用Gill Alt One MT Light),你应该这样写:
strbody= "<BODY style=" & Chr(34) & "font-family:Gill Alt One MT Light" & Chr(34) & ">" & YOUR_TEXT & "</BODY>"
#1
13
I did a little research and was able to write this code:
我做了一点研究,并且能够编写这段代码:
strbody = "<BODY style=font-size:11pt;font-family:Calibri>Good Morning;<p>We have completed our main aliasing process for today. All assigned firms are complete. Please feel free to respond with any questions.<p>Thank you.</BODY>"
apparently by setting the "font-size=11pt"
instead of setting the font size <font size=5>
, It allows you to select a specific font size like you normally would in a text editor, as opposed to selecting a value from 1-7 like my code was originally.
显然通过设置“font-size = 11pt”而不是设置字体大小,它允许您选择特定的字体大小,就像在文本编辑器中一样,而不是从1中选择一个值。 -7就像我原来的代码一样。
This link from simpLE MAn gave me some good info.
来自simpLE MAn的这个链接给了我一些很好的信息。
#2
0
FYI I did a little research as well and if the name of the font-family you want to apply contains spaces (as an example I take Gill Alt One MT Light), you should write it this way :
仅供参考我也进行了一些研究,如果你要应用的font-family的名称包含空格(例如我采用Gill Alt One MT Light),你应该这样写:
strbody= "<BODY style=" & Chr(34) & "font-family:Gill Alt One MT Light" & Chr(34) & ">" & YOUR_TEXT & "</BODY>"