How to Quickly Print Selected Text in Your Outlook Message

At times, you may only want to print the selected text in an Outlook message instead of the whole message. In this case, it’s suggested to use the VBA code introduced in this post.

Actually, in my previous article – “How to Print the Selection of an Outlook Email”, I have introduced a way to print the selected text in message body. However, that way is too tedious and troublesome. Thus, here we will expose a quicker way, which is using Outlook VBA. It can print out the selection as soon as you press a specific button.

Quickly Print Selected Text in Your Outlook Message

Print Selected Text in Outlook Message

  1. To start with, launch your Outlook program properly.
  2. Then, after entering the main Outlook window, press “Alt + F11” key buttons.
  3. Next you will get access to Outlook VBA editor window in success.
  4. At this point, you could open a blank module or directly insert a new module.
  5. Subsequently, you’ll be required to copy and paste the following VBA code to this module window.
Sub PrintSelectedTextinMessageBody()
    Dim objMail As Outlook.MailItem
    Dim objInspector As Outlook.Inspector
    Dim objWordDocument As Word.Document
    Dim objWordSelection As Word.Selection
    Dim objFileSystem As Object
    Dim strTextFile As String
    Dim objTextFile As Object
 
    'Get the current email message
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
 
    If Not objMail Is Nothing And objMail.Class = olMail Then
 
       Set objInspector = objMail.GetInspector
       If objInspector.EditorType = olEditorWord Then
          'Get the selected Text
          Set objWordDocument = objInspector.WordEditor
          Set objWordSelection = objWordDocument.Application.Selection
 
          'Input the selected Text to a New TXT file
          Set objFileSystem = CreateObject("Scripting.FileSystemObject")
          strTextFile = "E:\" & objMail.Subject & " " & Format(Now, "YYYY-MM-DD hh-mm-ss") & " .txt"
          Set objTextFile = objFileSystem.CreateTextFile(strTextFile, True)

          objTextFile.WriteLine (objWordSelection.Text)
          objTextFile.Close
 
          'Print the TXT file
          Shell ("notepad.exe /p " & strTextFile)
 
          'Delete the TXT file
          objFileSystem.DeleteFile (strTextFile)
      End If
    End If
End Sub

VBA Code - Print Selected Text in Your Outlook Message

  1. After that, for convenient check, you had better add the new macro to Quick Access Toolbar or ribbon of message window.
  2. Later change your Outlook macro settings to ensure macro is permitted.
  3. Eventually, you can have a try.
  • Open an email in its own window as usual.
  • Then select the text which you want to print.
  • Next click the macro button in Quick Access Toolbar.Select Text & Run Macro
  • At once, the selected text will be extracted into a new Text file and then the Text file will be printed out.

Keep Clam in Case of PST Damage

No one can keep calm when encountering PST corruption. However, as we know, any decisions made in panic and rush can make further damage. Therefore, it is necessary to calm down as soon as possible, which can be realized only when you can confirm that later Outlook recovery must be successful. In this case, there are two ways. One is to retrieve data from recent PST backups. And the other one is to resort to a potent and reputable tool like DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt sql and outlook repair software products. For more information visit www.datanumen.com

One Comment

  1. Comment by John:

    It isn’t working for me :(.. A dialog / debugger opens with this high lit objWordDocument As Word.Document

    Apart from that … Thank you!