Fix Excel VBA Compile Errors and Run-Time Error 438
Question details
The user needs to correct VBA compile errors and run-time error 438 in translated code.

- Product
- Microsoft Excel VBA
- Device & OS
- not provided
- Scenario
- Running translated VBA code that calls procedures and configures worksheet printing.
- Observed behavior
- The code fails to compile or raises error 438 when an object does not support a property or method being called.
Open the workbook and identify the module containing the translated code. In the VBA editor, make sure the Project Explorer is visible so you can check related procedures and modules.
Correct VBA names and declarations, then compile the project
Use this approach to find inconsistent variable and procedure names before running the macro.
In Excel, open the Developer tab and select Visual Basic. In Project Explorer, open the module containing the macro.
Add Option Explicit at the top of each module, before any procedures. Declare variables with Dim and assign values before using them; use Set when assigning an object reference.
Compare each procedure call with its definition. For example, change a call to print_sheet_risk_assessment if the intended procedure is named print_sheet_RISK_ANALYSIS. Check whether print_area and area_print should refer to the same variable, and use the intended name consistently.
Search the modules in Project Explorer for each called procedure, including management and worksheet-clearing routines. Correct the call, add the missing procedure, or remove the call if it is not needed.
Select Debug > Compile VBAProject. Fix the highlighted error and compile again after each group of corrections until the project compiles.

Debug unsupported VBA properties and methods
Use this approach when the macro raises run-time error 438.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files to make the move easier, while continuing to use Excel to debug Excel-specific VBA errors.

Frequently Asked Questions
What does VBA run-time error 438 mean?
It means the object used on a line does not support the property or method being called. Select Debug in the error dialog and inspect the object and member on the highlighted line.
How do I find undeclared variables in a VBA project?
Add Option Explicit at the top of each module, then select Debug > Compile VBAProject in the VBA editor. Declare any variables highlighted by the compiler.
Why can't VBA find a procedure that the macro calls?
The call may use a different name, or the procedure may be missing or inaccessible. Search the project modules for its definition and correct the call or provide the required procedure.
How do I fix an invalid PageSetup property?
In the VBA editor, inspect the worksheet's PageSetup statement and compare the property name with the supported PageSetup members. Replace an invalid name with the property needed for the intended print setting.




