How to Fix Excel VBA Application.Caller Runtime Error 1004
Question details
The user is encountering Runtime Error 1004 when trying to use Application.Caller in an Excel VBA macro assigned to a shape or button.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- A user assigns a macro to a shape or button to retrieve the clicked object's cell location in a spreadsheet.
- Observed behavior
- The macro throws Runtime Error 1004 when executing ActiveSheet.Buttons(Application.Caller).Name, and clicking the shape still runs the code even when Design Mode is active.
Ensure the Developer tab is enabled in your Excel ribbon and that macros are permitted to run in your Trust Center settings.
Use Correct Object Referencing for Application.Caller
Resolve Runtime Error 1004 by using the appropriate object collection based on what the macro is assigned to.
When an Excel macro is assigned to a graphic object, Application.Caller returns the name of that object. If your object is an inserted shape rather than a Form Control Button, calling it via the Buttons collection will fail.
Determine whether your clickable object is a Form Control Button or an inserted Shape (like a rectangle or icon).
If you are using a Shape, open your VBA module and change ActiveSheet.Buttons(Application.Caller).Name to ActiveSheet.Shapes(Application.Caller).Name.
To find the exact cell underlying the clicked object, use the TopLeftCell property by writing ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address.

Safely Edit Macros Assigned to Shapes
Learn how to bypass macro execution when editing shape controls, as Design Mode does not block shape clicks.
Fix Macros and Run VBA Seamlessly with WPS Spreadsheet
WPS Office includes robust VBA support, allowing you to run, edit, and debug macros efficiently with full compatibility for Excel's Application.Caller properties and object collections.
- 1. Open your macro file: Launch WPS Office and open your macro-enabled spreadsheet (.xlsm).
- 2. Access the VBA Editor: Navigate to the Developer tab and click 'Macros' or 'Visual Basic' to open the editor interface.
- 3. Edit and run: Modify your Application.Caller references, save the changes, and click your shapes to execute your assigned macros flawlessly.

Frequently Asked Questions
Why does ActiveSheet.Buttons(Application.Caller) throw an error?
This error occurs if the object you clicked is an inserted Shape rather than a Form Control button. The VBA engine cannot find the caller name in the 'Buttons' collection. You should use the 'Shapes' collection instead.
How can I find the cell address of the clicked button?
You can find the underlying cell address using the TopLeftCell property in VBA. The code snippet ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address will return the exact cell reference.
Why does my macro run even when Design Mode is turned on?
Design Mode only pauses the functionality of ActiveX controls. Standard inserted Shapes and Form Controls are unaffected by Design Mode and will continue to execute their assigned macros when clicked.
How do I access the Object Browser in VBA?
Open the Visual Basic Editor from the Developer tab, click the 'View' menu, and select 'Object Browser'. Alternatively, you can simply press the F2 key while in the editor window.




