Chris Williamson
Board Regular
- Joined
- Oct 16, 2010
- Messages
- 83
Hi,
I have got here a very simple macro that copies three values to a worksheet from a userform and then it opens a new email message and it pastes these values into the email message.
The userform has 3 text boxes and 1 command button:
TextBox1
TextBox2
TextBox3
CommandButton1
What I am trying to do is to change the font name to "Arial" and the font size to "20" on the body of the email message, what do I need to add in my vba macro code to do this?
Thank you
Chris
Here is my macro:
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Data_Sheet")
'copy the data to the spreadsheet
ws.Range("A1").Value = Me.TextBox1.Value 'Line 1
ws.Range("A2").Value = Me.TextBox2.Value 'Line 2
ws.Range("A3").Value = Me.TextBox3.Value 'Line 3
'reset the data back to default
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox1.SetFocus
Unload Me
' open microsoft outlook for the new email message
Set olApp = CreateObject("Outlook.Application")
Set newmessage = olApp.CreateItem(0)
newmessage.To = "name@hotmail.co.uk"
'Message Body
newmessage.Body = "Line 1: " & Worksheets("Data_Sheet").Range("A1").Value & Chr(13) _
& "Line 2: " & Worksheets("Data_Sheet").Range("A2").Value & Chr(13) _
& "Line 3: " & Worksheets("Data_Sheet").Range("A3").Value & Chr(13) & Chr(13) _
& "THANK YOU." & Chr(13) & Chr(13) _
& "**** EMAIL SIGNATURE GOES HERE ****"
newmessage.Subject = "SUBJECT LINE GOES HERE"
newmessage.Display
Set olApp = Nothing
Set newmessage = Nothing
End Sub
I have got here a very simple macro that copies three values to a worksheet from a userform and then it opens a new email message and it pastes these values into the email message.
The userform has 3 text boxes and 1 command button:
TextBox1
TextBox2
TextBox3
CommandButton1
What I am trying to do is to change the font name to "Arial" and the font size to "20" on the body of the email message, what do I need to add in my vba macro code to do this?
Thank you
Chris
Here is my macro:
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Data_Sheet")
'copy the data to the spreadsheet
ws.Range("A1").Value = Me.TextBox1.Value 'Line 1
ws.Range("A2").Value = Me.TextBox2.Value 'Line 2
ws.Range("A3").Value = Me.TextBox3.Value 'Line 3
'reset the data back to default
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox1.SetFocus
Unload Me
' open microsoft outlook for the new email message
Set olApp = CreateObject("Outlook.Application")
Set newmessage = olApp.CreateItem(0)
newmessage.To = "name@hotmail.co.uk"
'Message Body
newmessage.Body = "Line 1: " & Worksheets("Data_Sheet").Range("A1").Value & Chr(13) _
& "Line 2: " & Worksheets("Data_Sheet").Range("A2").Value & Chr(13) _
& "Line 3: " & Worksheets("Data_Sheet").Range("A3").Value & Chr(13) & Chr(13) _
& "THANK YOU." & Chr(13) & Chr(13) _
& "**** EMAIL SIGNATURE GOES HERE ****"
newmessage.Subject = "SUBJECT LINE GOES HERE"
newmessage.Display
Set olApp = Nothing
Set newmessage = Nothing
End Sub
Last edited: