How to Find Unicode Character Codes for VBA ChrW in Word
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.

- 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.
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.
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.
Highlight the special character (such as ✘) inside your Word document.
Press the Alt and X keys simultaneously on your keyboard. The character will instantly transform into its corresponding hexadecimal code (e.g., 2718).
Open your VBA editor and use this hexadecimal code inside the ChrW function by prefixing it with '&H'. For example, type ChrW(&H2718).

Find the Character Code via the Symbol Menu
Use the built-in Symbol dialog box in Word to look up the exact hexadecimal Unicode value without modifying your text.
Extract the Decimal Code using the VBA Immediate Window
Run a quick command directly in the VBA editor to get the decimal equivalent of the character, which can be used without the hexadecimal prefix.
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. Download and Install WPS Office: Get the latest version of WPS Office and open your text document in WPS Writer.
- 2. Access the Developer Tools: Navigate to the Developer tab on the top ribbon and click on the Visual Basic Editor icon.
- 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. Execute the Macro: Run your macro to instantly process your text and replace the placeholder text with the exact Unicode symbols you configured.

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.




