Skip to main content

How to insert specific text at cursor when composing message in outlook? 

Author: Xiaoyang Last Modified: 2020-05-22

Supposing, you have some specific text strings which are used frequently when composing the email message, so, you would like to insert the text at the current position of the cursor in the mail body automatically without manually typing them again and again. This article, I will talk about an easy method for solving this task quickly.

Insert specific text or current date at cursor when composing message with VBA code

Insert specific text or current date at cursor when composing message with VBA code

The following VBA code can help you to insert a specific text string or current date at the cursor position, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. And then, click Insert > Module, copy and paste below code into the opened blank module:

VBA code: Insert specific text or current date at cursor

Option Explicit
Public Sub InsertInfoToSelection()
    Dim xDoc As Word.Document
    Dim xSel As Word.Selection
    On Error Resume Next
    Select Case TypeName(Application.ActiveWindow)
        Case "Explorer"
            Set xDoc = Application.ActiveExplorer.Selection(1).GetInspector.WordEditor
        Case "Inspector"
            Set xDoc = Application.ActiveInspector.WordEditor
    End Select
    Set xSel = xDoc.Application.Selection
    xSel.InsertBefore Format("ExtendOffice")
    Set xDoc = Nothing
    Set xSel = Nothing
End Sub

Note: In the above code, ExtendOffice is the specific text that you want to insert, if you need to insert current date instead of the text string, please change the text in this script xSel.InsertBefore Format("ExtendOffice") to xSel.InsertBefore Format(Now, "DD/MM/YYYY").

3. Then, save and close the code window, create a new email, and in the Message window, click Customize Quick Access Toolbar drop down, and choose More Command, see screenshot:

doc insert text at cursor 1

4. In the Outlook Options dialog box, please do the following operations:

(1.) Select Macros from the Choose command from drop down;

(2.) Click the macro name you have inserted;

(3.) Then, click Add button to add this macro to the Customize Quick Access Toolbar list box.

doc insert text at cursor 2

5. And then, click OK button to close the dialog box, now, the macro icon has been inserted into the Customize Quick Access Toolbar. Put the cursor where you want to insert the text, and then click this macro button, the specific text will be inserted at once, see screenshot:

doc insert text at cursor 3

Insert specific text at any location when composing message:

With Kutools for Outlook's Auto Text feature, you can create an auto text, and then insert it anywhere when composing message as you need.

doc insert text at cursor 4

Kutools for Outlook: with more than 100 handy Excel add-ins, free to try with no limitation in 60 days. Download and try the free trial now!

Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!

πŸ€– Kutools AI : Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...

πŸ“§ Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

πŸ“¨ Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

πŸ“ Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

πŸ‘ One-click Wonders: Reply All with Incoming Attachments  /   Anti-Phishing Emails  /  πŸ•˜Show Sender's Time Zone ...

πŸ‘©πŸΌβ€πŸ€β€πŸ‘©πŸ» Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Instantly unlock Kutools for Outlook with a single clickβ€”permanently free. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2



Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations