outlook

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
hi,

Does any know how to add the subject line into email body, rather than copy & paste into ?

Hoping someone can 'rescue me' & thank you for your help.


KR
Trevor3007
 
Did you read:
'Note: This code requires references to Word, via Tools|References


hello Macropod,

Thank you for your help. I am bit of a numpty here as i canot find 'via Tools|References' i have looked in both word & outlook but I am still :banghead:

would you kindley guide me through the darkness & into light?

KR
Trevor 3007
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
In the Outlook VBE, choose Tools|References then scroll down till you find the Microsoft Word library.
 
Upvote 0
In the Outlook VBE, choose Tools|References then scroll down till you find the Microsoft Word library.

hi & good morning Macropod,

thanks for getting back to me.

I followed your guide & the only 'word' reference I could find is 'Microsoft word 16.0 object library ( which I ticked). I then ran the vb/macro & throw up the debug error:-

run time error '429'
activex component can't create object

I choose debug & the following is highlighted in yellow:-

Word.Selection.InsertBefore " " & olMail.Subject

kind regards
Trevor3007
 
Upvote 0
OK, try replacing that line with:
wdDoc.Application.Selection.InsertBefore " " & olMail.Subject
 
Upvote 0
OK, try replacing that line with:
wdDoc.Application.Selection.InsertBefore " " & olMail.Subject



hi there Marcopod,


great news it works a treat & thank you.


is it possible to insert only the end bit ( WC:13/11/17) in to a particular line of the body text?
 
Upvote 0
OK, try replacing that line with:
wdDoc.Application.Selection.InsertBefore " " & olMail.Subject



thank you Macropad,

with a bit of tweaking in the body, I nearly got there :}.....but

Is it possible to choose the applicable line ( IE 8 ) for the text to be place. ATM I have delete a few lines to get the VB to insert the applicable but this is a 'customers' template & therefore this cannot altered.

many thanks in advance & your assistance has been aces.

Kindest regards
Trevor3007
 
Upvote 0
It would be really helpful if you'd said clearly from the outset what you wanted. As coded, the macro simply inserts the content at wherever your selection/insertion point is. In order to code the macro to insert the content at a particular location, I'd have to know exactly what that location is. It would have to be either: a fixed point in the email (saying something like 'line 8' is meaningless given what can happen when the email window is resized); or an offset from a known string. So far, you haven't given me anything I could work with. I have no idea what you mean by "I have delete a few lines to get the VB to insert the applicable".
 
Last edited:
Upvote 0
It would be really helpful if you'd said clearly from the outset what you wanted. As coded, the macro simply inserts the content at wherever your selection/insertion point is. In order to code the macro to insert the content at a particular location, I'd have to know exactly what that location is. It would have to be either: a fixed point in the email (saying something like 'line 8' is meaningless given what can happen when the email window is resized); or an offset from a known string. So far, you haven't given me anything I could work with. I have no idea what you mean by "I have delete a few lines to get the VB to insert the applicable".


Hi Macropod,

Yes you are correct, I should of given you the whole nine. Sorry for this oversight.
I will endeavour to give you the full tale.

You sorted the subject bit & when I tested it & from the odd ‘debug’ run great. However,
I have a customer email template that get sent at the end of each working week. The subject line is always the same apart from the date. This date is to be added into the body of the email at end of the applicable text on line 8.

The code you sorted for me ends up on line 1, but needs to go to the end of the text in line 8.
In order for the ‘date’ to be placed correctly, I have remove a few lines from the original body
Does this give you a better understanding?

Again, my sincere apologies for my previous.

KR
Trevor3007
 
Upvote 0
The subject line is always the same apart from the date. This date is to be added into the body of the email at end of the applicable text on line 8.

The code you sorted for me ends up on line 1, but needs to go to the end of the text in line 8.
As I already said
As coded, the macro simply inserts the content at wherever your selection/insertion point is.
...
saying something like 'line 8' is meaningless given what can happen when the email window is resized
The text inserted by the code does not only "ends up on line 1" - it ends up wherever your insertion point is when you run it. If you want it to go somewhere on what you're calling line 8, simply position the insertion point there before running the code; otherwise, you're going to have to be a lot more precise about defining the insertion position in a way that is independent of the window size.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top