How to Use ZWSP in Microsoft Word?

What is Zeo-Width Space (ZWSP)?

zero-width space (ZWSP) is a non-printing character used in text processing to indicate word boundaries without displaying a visible space. It’s particularly useful in scripts that don’t use explicit spacing between words, such as Thai, Khmer, and Japanese

Here are some key points about zero-width spaces:

  • Unicode Character: The zero-width space is represented by the Unicode character U+200B.
  • HTML Representation: In HTML, it can be represented as ​​, or ​.
  • Usage: It marks potential line breaks without adding a visible space, similar to a soft hyphen but without displaying a hyphen when the line breaks
  • Applications: It’s used to control line breaks in text, especially in justified text where inter-character spacing might be adjusted

How to Use ZWSP in Microsoft Word without it being detected as a spelling error.

  1. Using the Symbol Dialog:

    • Place your cursor where you want to insert the zero-width space.
    • Go to the Insert tab on the ribbon.
    • Click on Symbol and then More Symbols.
    • In the Symbol dialog box, go to the Special Characters tab.
    • Select No-Width Optional Break and click Insert.
  2. Using a Keyboard Shortcut:

    • You can assign a keyboard shortcut to the zero-width space for easier access. For example, you can use Ctrl + Space to insert it
  3. Using Unicode:

    • Place your cursor where you want the zero-width space.
    • Press Alt and type 8203 on the numeric keypad, then release Alt. This will insert the zero-width space character (U+200B)

Automate insert ZWSP into MS Word with Macro script (Not Success yet)

  1. Open the VBA Editor:
    • Press Alt + F11 to open the VBA editor in Word.
  2. Insert a New Module:
    • In the VBA editor, go to Insert > Module to create a new module.
  3. Write the Script:
    • Copy and paste the following VBA code into the module:
Sub InsertZWSPInConnectiveVerbs()
    Dim doc As Document
    Dim rng As Range
    Dim verbs As Variant
    Dim verb As Variant
    Dim zwsp As String
    
    ' Define a list of connective verbs
    verbs = Array("is", "are", "was", "were", "be", "being", "been")
    
    ' Zero-width space character
    zwsp = ChrW(&H200B)
    
    ' Set the document
    Set doc = ActiveDocument
    
    ' Loop through each word in the document
    For Each rng In doc.Words
        ' Check if the word is a connective verb
        For Each verb In verbs
            If InStr(1, rng.Text, verb, vbTextCompare) > 0 Then
                ' Debugging statement
                Debug.Print "Found verb: " & rng.Text
                ' Insert ZWSP at the beginning of the verb
                rng.Text = Replace(rng.Text, verb, zwsp & verb)
            End If
        Next verb
    Next rng
End Sub
  1. Run the Script:
    • Close the VBA editor and return to your Word document.
    • Press Alt + F8 to open the Macro dialog box.
    • Select InsertZWSPInConnectiveVerbs and click Run.

References:


@lerlerchan by LerLer Chan

lerlerchan



|


|


|


|


Ler Travel Diary is using
Web Hosting and n8n on Hostinger

To be a smart saver, check out
ShopBack for more information.

Enjoy SGD5 discount voucher on
Klook with code 53E7UD

Need discount for your travels? Check out our travel deals page.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *