At times, you may accidentally use two or more fonts when composing an email. If you want to keep all characters in same font, you need to check the fonts. This post will introduce you a way to effectively perform such checking via VBA.
For an official email, you had better keep the fonts same and unified. However, at times, you may accidentally use several fonts in an email. For instance, you copy a part of texts to your email and keep them in original format. Thus, the fonts may be different from the original email content. If you are composing a pretty long email, you must be reluctant to checking fonts of all characters one by one. Hence, here we will teach you a handier way to quickly check fonts.
Check If Only One Font Is Used Across the Whole Email
- At the very outset, launch Outlook program.
- Then, launch VBA editor via “Alt + F11” as per “How to Run VBA Code in Your Outlook“.
- Next, enable reference to “Microsoft Scripting Runtime” according to “How to Add an Object Library Reference in VBA“.
- After that, copy the code below into the unused module or project.
Sub CheckIfFontsAreSame() Dim objMail As Outlook.MailItem Dim objMailDocument As Word.Document Dim objDictionary As New Scripting.Dictionary Dim varFonts As Variant Dim i As Integer Dim strlist As String Select Case Outlook.Application.ActiveWindow.Class Case olInspector Set objMail = ActiveInspector.CurrentItem Case olExplorer Set objMail = ActiveExplorer.Selection.Item(1) End Select Set objMailDocument = objMail.GetInspector.WordEditor Set objDictionary = CreateObject("Scripting.Dictionary") 'Add all used fonts to dictionary For Each objCharacter In objMailDocument.Characters strFontName = objCharacter.Font.Name If objDictionary.Exists(strFontName) = False Then objDictionary.Add strFontName, 1 End If Next If objDictionary.Count = 1 Then MsgBox "All email charatcers use " & objDictionary.Keys(0) & "!", vbInformation + vbOKOnly Else varFonts = objDictionary.Keys For i = LBound(varFonts) To UBound(varFonts) strlist = strlist & (i + 1) & "." & varFonts(i) & vbCr Next MsgBox "There are " & objDictionary.Count & " fonts used in this email, as follows:" & vbCrLf & strlist End If End Sub
- Subsequently, exit the VBA editor and add this macro to Quick Access Toolbar (QAT).
- Eventually, follow the steps below to try it.
- First off, select or open an email.
- Then, if all characters use the same font, you will receive a message like this.
- But, if there is more than one font used in this email, you will get another message like this.
Effective Precautions against PST Data Loss
As long as you take sufficient and effective precautions, you will surely be able to escape from Outlook data loss. For example, you should persist in making regular data backups for your computer, including the PST files. Besides, you should keep all potentially malicious factors at bay. Last but not least, it is prudent and wise to get hold of a reliable and expert Outlook recovery 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 corrupted sql and outlook repair software products. For more information visit www.datanumen.com