# New Macro

## Settings&#x20;

{% hint style="info" %}
This object depends either on the "**New Excel**" or on the "**Open Excel**" objects to work.
{% endhint %}

![](/files/-MVMFs3MaGOdRDLuicsQ)

| Field                  | Descriptive                                                     |
| ---------------------- | --------------------------------------------------------------- |
| Title                  | Object Title                                                    |
| Object Identifier Name | Singular object name of the object to create the macro in Excel |
| Select Main Object     | Option to select an Excel sheet                                 |
| Macro Name             | Macro name                                                      |
| Run Macro              | Execute the created macro                                       |
| Select Cells           | Select the cells for the macro execution                        |
| Starting Cell          | Initial cell of the selection                                   |
| Final Cell             | Final selection cell                                            |
| Script                 | VBA Script                                                      |

## Example

To create a new macro in an Excel spreadsheet file you need to follow a few steps with a pre-existing file:

1 - Select the **"Open Excel"** object from the "**Excel"** menu and drag it to your working area.

* First you must define a unique name for the object in the "**Object Identifier Name**" field, inform the complete directory containing the name and the extension of the file and then set a password if it is required.

2 - Then you should select the "**New Macro**" object in the "**Excel**" menu, define a unique name for the object in the "**Object Identifier Name**" field, select the main object defined when opening the Excel file, define the macro name, select the "Run Macro" option and then write the VBA script.

* Caso selecionada a opção "**Executar Macro**", será exibida a opção "**Selecionar Células**". Ao selecionar essa opção, será necessário informar o valor para a "**Célula Inicial**" e "**Célula Final**" para a execução da macro. - If you select the "**Run Macro**" option, the "**Select Cells**" option will be displayed. When you select this option, you will need to enter the values for the "**Starting Cell**" and the **"Final Cell**" fields.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboteasy.tech/studio-en/studio/objetos/excel/criar-macros.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
