Avatar of Jesper E Magnussen
Jesper E Magnussen
Flag for Norway asked on

VBA to insert text in subject line in Outlook

Hi,

Found a bit of VBA code to place text in the subject line of Outlook:

Sub New_Subject_Email()
Dim MItem As MailItem
Set MItem = Application.CreateItem(olMailItem)
MItem.subject = "36355 XXXXXXXXXX - "
MItem.Display
End Sub

It Works, but I would love to have the cursor ready (blinking) to type after the "36355 XXXXXXXXXX - " when I use the TAB key to activate the Subject line.

How would I change the VBA code accordingly?
OutlookVBA

Avatar of undefined
Last Comment
Daniel Pineault

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Daniel Pineault

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Karen Falandays

I am curious as to why you wouldn't just use a quick step to autofill the subject and any other info
Jesper E Magnussen

ASKER
Hi Daniel,

Checked it out, problem is that you come directly to the subject line, I would rather start with receiver name, use TAB key to move downwards and when in subject line, cursor ready to start typing after the pre-typed text.

I'm a project director and have several projects with different project numbers and names, having always project number and name I can sort the mails automatically, hence the question.

Brgds
Jesper
Jesper E Magnussen

ASKER
Hi Karen,

Quick  step works fine, but as above, I would like to have cursor ready to type when I, by using TAB key, reaches down to Subject line and have cursor ready after the text already inserted by code.

Brgds
Jesper
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Jesper E Magnussen

ASKER
HI,

Above code works fine, only I need the addition to get the cursor ready to type and the end of the text already placed in the subject line, when the subject line gets focus by jumping down using TAB key.

Brgds
Jesper
Jesper E Magnussen

ASKER
No solution found for having cursor ready at the end of the pre-printed text in the subject line.
Daniel Pineault

As I originally stated, I think you'd have to get into using windows APIs for this.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.