How to Fix VBA Error 438 in JSON Parsers on Windows 11
Question details
The user needs to fix a VBA Error 438 occurring during JSON parsing, which prevents macros from running properly after a recent Windows update.

- Product
- Microsoft Excel / VBA
- Device & OS
- Windows 11 (Build 26100)
- Scenario
- Running an Excel VBA macro that uses a JSON parser to iterate through keys using a For Each loop.
- Observed behavior
- The macro throws 'Error 438: Object doesn't support this property or method' because the returned JSON keys object no longer supports For Each enumeration on newer Windows 11 builds.
Before modifying your macro code, identify which specific JSON parsing script is throwing the error and ensure your workbook is saved to prevent accidental code loss.
Convert JSON Keys to an Array to Avoid Enumeration Errors
Modify your VBA code to convert the returned keys object into a comma-delimited string, split it into an array, and iterate using index numbers instead of a For Each loop.
In newer versions of Windows 11 (such as build 26100), certain COM objects returned by external JSON parsers lose their compatibility with the standard 'For Each' enumeration method in VBA. Bypassing the object enumeration by converting the data into a standard VBA array will permanently resolve this compatibility issue.
Press ALT + F11 in Excel to open the Visual Basic for Applications (VBA) Editor, and locate the module containing your JSON parsing code.
Find the line of code using a 'For Each' loop to iterate through the JSON keys (e.g., For Each key In KeysObject), which is where Error 438 is triggered.
Declare a string variable and convert the keys object into a comma-separated string using the CStr function. For example: a = CStr(KeysObject).
Declare an array variable and populate it by splitting the newly created string. Use the code: KeysArray = Split(a, ",").
Replace your old 'For Each' loop with a standard For loop that iterates through the array indices. Use: For i = 0 To UBound(KeysArray). Inside the loop, reference the keys using KeysArray(i).

Run and Edit VBA Macros Seamlessly in WPS Office
WPS Spreadsheets provides robust built-in support for VBA macros, offering a highly stable environment for running complex scripts and JSON parsers without the unexpected COM object glitches sometimes seen in other software updates.
- 1. Download WPS Office: Download and install the latest version of WPS Office, ensuring you select the package that includes VBA support.
- 2. Open your macro workbook: Launch WPS Spreadsheets and open your existing .xlsm or .xlsb workbook.
- 3. Access the VBA Editor: Navigate to the 'Developer' tab on the top ribbon and click on 'Visual Basic' to open the familiar VBA Editor interface.
- 4. Apply the array fix: Locate your JSON parser module and easily apply the CStr and Split array conversion fix.
- 5. Run your modified macro: Save your code and run the macro to verify that the JSON data is parsed perfectly without encountering Error 438.

Frequently Asked Questions
What does VBA Error 438 mean?
VBA Error 438, 'Object doesn't support this property or method,' occurs when a script tries to execute a method or access a property that the specific object does not possess. In this scenario, it happens when trying to use a 'For Each' loop on a JSON object that is not recognized as an enumerable collection.
Why did this VBA error only appear after a Windows 11 upgrade?
Certain Windows 11 updates, specifically builds like 26100, introduced underlying changes to system libraries and COM objects. This caused previously enumerable objects returned by some third-party JSON parsers to lose their 'For Each' compatibility, triggering the error.
Can I still use the For Each loop for other objects in VBA?
Yes, standard VBA collections, arrays, and native Excel objects like ranges or worksheets still fully support 'For Each' enumeration. This error is strictly localized to certain external dictionary or JSON parser objects.
How does the Split method bypass this issue?
By using CStr(), you force the object to output its default string representation, which is typically a comma-separated list of keys. The Split() function converts this text string into a native VBA zero-based array, which VBA can always iterate through safely using a standard For loop.




