# SaveToMemory Method

> Saves the document or the selection in a given format to a one-dimensional byte array; the Basic example copies text to a second control with LoadFromMemory.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Text Control ActiveX > API Reference > TXTextControl > SaveToMemory Method
- **395 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemory-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemory-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemory-method/llms-full.txt

---

Returns a one-dimensional byte array containing text data in a specified format.

### Syntax

```vbscript
TXTextControl.SaveToMemory [Format[, CurSelection]]
```

### Parameters

| Parameter | Description |
|---|---|
| Format | Optional. Specifies a format identifier. When this parameter is not specified the data is saved in the internal Text Control format (3). See the Format parameter of the [Save](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/save-method/llms-full.txt) method for possible format identifiers. |
| CurSelection | Optional. When set to True the current selection is saved. When omitted or set to False or when no selection exists all the control contents are saved. |

### Return Value

The method returns a one-dimensional array of bytes, containing the saved data.

### Data Types

| Name | Data type |
|---|---|
| Format | Integer |
| CurSelection | Boolean |
| Return value | One-dimensional Byte Array |

### Examples

This Basic example copies the currently selected text from the first Text Control and inserts it at the current input position of a second Text Control:

```vbscript
Dim data() As Byte
data = TXTextControl1.SaveToMemory(3, True)
TXTextControl2.LoadFromMemory data, 3, True
```

### See Also

- [PDF Export](https://docs.textcontrol.com/tx-text-control-activex/pdf/llms-full.txt)
- [Save Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/save-method/llms-full.txt)
- [LoadFromMemory Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/loadfrommemory-method/llms-full.txt)
- [Programming Category: Loading, Saving and Database Support](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/load-save/llms-full.txt)

---

## Nearby

- **Previous:** [SaveDialog Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savedialog-method/llms-full.txt)
- **Next:** [SaveToMemoryBuffer Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemorybuffer-method/llms-full.txt)
