# SaveToMemoryBuffer Method

> Saves the document or selection in a given format to a buffer of the same type as the first parameter, a string or a byte array, for example RTF in a string.

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

---

Returns a buffer containing text data in a specified format. The buffer can be a string or a one-dimensional byte array. To inform Text Control which kind of buffer is to be returned specify the buffer as the first parameter.

### Syntax

```vbscript
TXTextControl.SaveToMemoryBuffer DataBuffer[, Format[, CurSelection]]
```

### Parameters

| Parameter | Description |
|---|---|
| DataBuffer | Specifies a buffer that can be a string or a byte array. Text Control uses this parameter to get the type of the return buffer. |
| 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 buffer, containing the saved data.

### Data Types

| Name | Data type |
|---|---|
| DataBuffer | String or One-dimensional Byte Array |
| Format | Integer |
| CurSelection | Boolean |
| Return value | Same Type as DataBuffer |

### 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 using RTF format:

```vbscript
Dim RTF As String
RTF = TXTextControl1.SaveToMemoryBuffer(RTF, 5, True)
TXTextControl2.LoadFromMemory RTF, 5, 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)
- [SaveToMemory Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemory-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:** [SaveToMemory Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/savetomemory-method/llms-full.txt)
- **Next:** [ScrollBars Property](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/scrollbars-property/llms-full.txt)
