VBA & Macro Problems

How to Fix Excel VBA Application.Caller Runtime Error 1004

Phi Hung VoPhi Hung Vo Nov 4, 2026 870 views

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.

How to Fix Excel VBA Application.Caller Runtime Error 1004
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.
Before you start

Ensure the Developer tab is enabled in your Excel ribbon and that macros are permitted to run in your Trust Center settings.

Solution 1Recommended

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.

1
Identify your object type

Determine whether your clickable object is a Form Control Button or an inserted Shape (like a rectangle or icon).

2
Update the VBA syntax

If you are using a Shape, open your VBA module and change ActiveSheet.Buttons(Application.Caller).Name to ActiveSheet.Shapes(Application.Caller).Name.

3
Retrieve the cell location

To find the exact cell underlying the clicked object, use the TopLeftCell property by writing ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address.

Use Correct Object Referencing for Application.Caller
Debugging Tip: You can use the Object Browser to explore properties. Press F2 in the Visual Basic Editor to search for TopLeftCell and other shape-related properties.
Efficient VBA Support

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. 1. Open your macro file: Launch WPS Office and open your macro-enabled spreadsheet (.xlsm).
  2. 2. Access the VBA Editor: Navigate to the Developer tab and click 'Macros' or 'Visual Basic' to open the editor interface.
  3. 3. Edit and run: Modify your Application.Caller references, save the changes, and click your shapes to execute your assigned macros flawlessly.
Full compatibility with Microsoft Excel VBA scripts and macro formats (.xlsm).Advanced Visual Basic Editor for seamless code debugging.Free and lightweight alternative to heavy spreadsheet applications.
microsoft office alternative - wps office

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.