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.
Print Selected Text in Outlook Message
- To start with, launch your Outlook program properly.
- Then, after entering the main Outlook window, press “Alt + F11” key buttons.
- Next you will get access to Outlook VBA editor window in success.
- At this point, you could open a blank module or directly insert a new module.
- 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
- After that, for convenient check, you had better add the new macro to Quick Access Toolbar or ribbon of message window.
- Later change your Outlook macro settings to ensure macro is permitted.
- 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.
- 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.
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