VBA & Macro Problems

How to Fix a Word VBA Macro Replacing Japanese Brackets Incorrectly

Rana GarciaRana Garcia Nov 3, 2026 869 views

Question details

The user needs to correct a VBA macro that is replacing both opening and closing Japanese corner brackets with the same character.

How to Fix a Word VBA Macro Replacing Japanese Brackets Incorrectly
Product
Word
Device & OS
not provided
Scenario
Executing a Find and Replace VBA macro to convert Japanese corner brackets into standard English quotation marks.
Observed behavior
The macro incorrectly replaces both the opening and closing brackets with the identical character because the search range overlaps or is not properly reset after the first replacement.
Before you start

Ensure the Developer tab is enabled in your ribbon so you can access the Visual Basic Editor, and identify the exact Unicode values for the characters you are modifying (12300 for 「 and 12301 for 」).

Solution 1Recommended

Use Separate Range Objects and Collapse After Replacement

Resolve the issue by processing each bracket using an independent Range object and collapsing the range after every individual replacement operation.

When a single Range object is used for consecutive Find and Replace operations, the first replacement alters the text length and shifts the range focus. This often causes the subsequent search to target the wrong characters. Isolating the searches into separate Range objects prevents the first replacement from interfering with the second search.

1
Open the Visual Basic Editor

Press ALT + F11 to launch the Visual Basic Editor (VBE) and locate the module containing your specific Find and Replace macro.

2
Declare Separate Range Objects

Modify your code to declare two distinct Range variables, for example: 'Dim rngOpen As Range' and 'Dim rngClose As Range'.

3
Configure the First Replacement

Set up the first Range object to find the opening Japanese bracket. Use ChrW(12300) in the Find parameter and set the Replacement parameter to ChrW(8220) to insert a standard opening quote.

4
Collapse the Range

Immediately after executing the first replacement, collapse the range using 'rngOpen.Collapse Direction:=wdCollapseEnd' so the macro cursor moves past the replaced text.

5
Configure the Second Replacement

Set up the second Range object to find the closing Japanese bracket. Use ChrW(12301) for the Find parameter and ChrW(8221) for the Replacement parameter to insert a standard closing quote, then run the macro.

Use Separate Range Objects and Collapse After Replacement
Unicode Mapping: The opening Japanese bracket '「' corresponds to Unicode 12300, and the closing bracket '」' corresponds to Unicode 12301. The standard English curly quotes are Unicode 8220 (“) and 8221 (”).
Advanced Macro Support

Easily Manage and Edit VBA Macros with WPS Writer

WPS Office provides robust native support for VBA macros, allowing you to efficiently script and automate complex document formatting tasks, including advanced Find and Replace scenarios for Unicode characters.

  1. 1. Open WPS Writer: Launch WPS Writer and open the document containing the Japanese brackets you need to format.
  2. 2. Access the Visual Basic Editor: Navigate to the Developer tab on the top ribbon and click 'Macros' or 'Visual Basic' to bring up the macro editor.
  3. 3. Run Your Code: Paste your updated VBA script with the separate Range objects, click 'Run', and watch the characters convert correctly.
Fully compatible with Microsoft Word VBA macros and syntax.Advanced Find and Replace natively handles complex Unicode and double-byte characters.Features a lightweight, intuitive Visual Basic Editor for quick code adjustments.Free to download and optimized for heavy document processing.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Find and Replace macro replace both brackets with the exact same character?

This occurs when a single Range object is reused without being collapsed. The first replacement modifies the text layout, shifting the internal range boundaries so the second operation mistakenly applies its replacement to the wrong text.

What are the Unicode values for Japanese corner brackets?

The opening Japanese corner bracket (「) is Unicode 12300, and the closing Japanese corner bracket (」) is Unicode 12301. In VBA, you target these characters using the functions ChrW(12300) and ChrW(12301).

How do I collapse a Range in Word VBA?

You can collapse a Range object by calling its Collapse method, usually written as 'YourRange.Collapse Direction:=wdCollapseEnd'. This moves the logical insertion point to the very end of the text you just modified.