logo
search
Others

How to Find Unicode Character Codes for VBA ChrW in Word

John WilsonJohn Wilson Oct 23, 2026 868 views

Question details

The user needs to convert a specific symbol into a Unicode character code so it can be used safely with the ChrW function in Word VBA.

How to Find Unicode Character Codes for VBA ChrW in Word
Product
Word
Device & OS
not provided
Scenario
Writing VBA macros in Word where special Unicode characters need to be inserted or replaced programmatically.
Observed behavior
Pasting a special character directly into the VBA editor's Replacement.Text field produces a question mark because the editor cannot handle the character's native encoding.
Before you start

Ensure that the special character you want to convert is already inserted in your Word document, and verify that your Developer tab is enabled so you can access the Visual Basic Editor.

Solution 1Recommended

Use the Alt+X Shortcut to Find the Hexadecimal Code

This is the fastest method to reveal the Unicode hexadecimal code of any character directly within your Word document.

1
Select the character

Highlight the special character (such as ✘) inside your Word document.

2
Press Alt+X

Press the Alt and X keys simultaneously on your keyboard. The character will instantly transform into its corresponding hexadecimal code (e.g., 2718).

3
Implement in VBA

Open your VBA editor and use this hexadecimal code inside the ChrW function by prefixing it with '&H'. For example, type ChrW(&H2718).

Use the Alt+X Shortcut to Find the Hexadecimal Code
Font Dependency: While VBA will now correctly process the character using ChrW, the symbol will only display correctly in your final document if the applied font supports that specific Unicode glyph.
Advanced Macro Support in WPS Office

Use WPS Writer for Advanced Macro and VBA Development

WPS Office provides robust built-in support for macros and VBA, allowing you to easily manage Unicode characters and automate text replacement tasks seamlessly. You can comfortably write, run, and debug your existing Word macros in WPS Writer.

  1. 1. Download and Install WPS Office: Get the latest version of WPS Office and open your text document in WPS Writer.
  2. 2. Access the Developer Tools: Navigate to the Developer tab on the top ribbon and click on the Visual Basic Editor icon.
  3. 3. Write your VBA Code: Insert your macro script, using the ChrW function along with the correct Unicode character code to manipulate special symbols.
  4. 4. Execute the Macro: Run your macro to instantly process your text and replace the placeholder text with the exact Unicode symbols you configured.
Highly compatible with Microsoft Word document formats and VBA macrosLightweight software with fast execution speeds for heavy automationFamiliar user interface requiring zero learning curveComprehensive developer tools included for efficient coding
microsoft office alternative - wps office

Frequently Asked Questions

Why does my special character show as a question mark in the VBA editor?

The standard VBA editor uses ANSI encoding and does not fully support Unicode characters. Pasting a Unicode-only character directly into the editor converts it to a question mark because the editor does not recognize it. Using the ChrW function with the character's unique code circumvents this limitation.

What is the difference between Chr and ChrW in VBA?

The Chr function returns characters based on the system's default ANSI character set (0-255). The ChrW function returns a Unicode character, allowing you to utilize a much broader range of symbols, emojis, and international text characters that exceed standard ANSI limits.

How do I convert a hexadecimal code to decimal for ChrW?

You do not have to convert it. You can use the hexadecimal code directly in your VBA script by prefixing it with '&H' (for example, ChrW(&H2718)). If you prefer decimal, you can use the Immediate Window command '? AscW(Selection)' to output the decimal value automatically.

Will the ChrW function guarantee the symbol displays correctly in my document?

Not inherently. While ChrW correctly generates and inserts the underlying Unicode character, the visual representation depends entirely on whether the font applied to that section of text contains the specific glyph for that character.