VBA & Macro Problems

How to Use MoveRight wdCell in Excel VBA with Late-Bound Word

Anum MushtaqAnum Mushtaq Nov 3, 2026 868 views

Question details

The user needs to move the cursor one cell to the right in a Word document controlled by Excel VBA via late binding, but the wdCell constant is not recognized.

How to Use MoveRight wdCell in Excel VBA with Late Binding
Product
Excel VBA
Device & OS
not provided
Scenario
Automating Microsoft Word tasks from an Excel macro using late binding.
Observed behavior
Excel VBA throws an error or fails to recognize the constant 'wdCell' because the Word Object Library is not referenced in the project.
Before you start

Ensure that your Excel VBA macro successfully creates or retrieves the late-bound Word application object using CreateObject("Word.Application") before executing movement commands.

Solution 1Recommended

Use the Numeric Value for the wdCell Constant

Replace the Word-specific named constant with its underlying numeric value to maintain true late binding without needing external library references.

When using late binding, the host application (Excel) does not load the type library of the target application (Word). Therefore, Word-specific constants like 'wdCell' are completely unknown to Excel VBA.

To bypass this limitation, you must look up the numeric value of the constant and use it directly in your VBA code.

1
Identify the constant value

The numeric value for the Word constant 'wdCell' is 12.

2
Update the MoveRight command

Locate the line of code using the MoveRight method in your Excel VBA script.

3
Replace the named constant

Change 'objSelection.MoveRight Unit:=wdCell' to 'objSelection.MoveRight Unit:=12'.

4
Run the macro

Execute the macro again. The cursor should now successfully move one cell to the right within the Word table.

Best Practice: To make your late-bound code easier to read, you can declare the constant at the top of your Excel VBA module yourself: Const wdCell As Integer = 12.
Free Microsoft Office alternative

Experience Seamless VBA Compatibility with WPS Office

If you frequently work with macros and document automation, WPS Office offers a powerful, lightweight, and free alternative to Microsoft Office. WPS Spreadsheets and WPS Writer provide excellent support for VBA macros, allowing you to run your automated workflows without expensive subscriptions.

  1. 1. Download and Install: Get the free version of WPS Office from the official website and install it on your device.
  2. 2. Open your Macro File: Open your .xlsm or .docm files directly in WPS Spreadsheets or WPS Writer.
  3. 3. Enable Macros: Click 'Enable Macros' when prompted by the security warning to allow your VBA code to run seamlessly.
Highly compatible with Microsoft Excel (.xlsm) macro-enabled formatsIncludes a built-in VBA editor similar to Microsoft OfficeLightweight, fast, and completely free to downloadFamiliar tabbed interface with zero learning curve
QA img-9

Frequently Asked Questions

How can I find the numeric values of other Word VBA constants?

You can find constant values using the Object Browser. Open the VBA Editor in Microsoft Word (Alt + F11), press F2 to open the Object Browser, search for the constant name (like wdCell), and look at the details pane at the bottom to see its underlying numeric value.

What is the difference between early binding and late binding in VBA?

Early binding requires checking the specific object library in Tools > References, which gives you IntelliSense and named constants but binds the code to a specific software version. Late binding uses generic Object variables (e.g., CreateObject) without library references, making the code more version-independent but requiring you to use numeric values instead of named constants.

Why am I getting a 'Variable not defined' error for wdCell?

If you have 'Option Explicit' declared at the top of your Excel VBA module, VBA requires all variables to be defined. Since Excel does not natively recognize Word's 'wdCell' constant without a library reference, it treats it as an undeclared variable. Replacing it with the number 12 resolves the error.