Skip to content

Latest commit

 

History

History
50 lines (30 loc) · 1.47 KB

Excel.Workbook.CodeName.md

File metadata and controls

50 lines (30 loc) · 1.47 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Workbook.CodeName property (Excel)
vbaxl10.chm199086
vbaxl10.chm199086
Excel.Workbook.CodeName
236e97b8-2bb9-c3a9-b4da-b1c327acde95
05/29/2019
medium

Workbook.CodeName property (Excel)

Returns the code name for the object. Read-only String.

Syntax

expression.CodeName

expression An expression that returns a Workbook object.

Remarks

The value that you see in the cell to the right of (Name) in the Properties window is the code name of the selected object. At design time, you can change the code name of an object by changing this value. You cannot programmatically change this property at run time.

The code name for an object can be used in place of an expression that returns the object. For example, if the code name for worksheet one is Sheet1, the following expressions are identical.

Worksheets(1).Range("a1") 
Sheet1.Range("a1")

It's possible for the sheet name to be different from the code name. When you create a sheet, the sheet name and code name are the same, but changing the sheet name doesn't change the code name, and changing the code name (by using the Properties window in the Visual Basic Editor) doesn't change the sheet name.

Example

This example displays the code name for worksheet one.

MsgBox Worksheets(1).CodeName

[!includeSupport and feedback]