# Load Method

> Loads a file into the TXTextControl from an offset in a format such as TX, RTF, HTML, DOC, DOCX, XLSX, XML or text, replacing all text or the selection.

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

---

Loads text in a certain format from a file and inserts it into the Text Control.

### Syntax

```vbscript
TXTextControl.Load FileName[, Offset[, Format[, CurSelection]]]
```

### Parameters

| Parameter | Description |
|---|---|
| FileName | Specifies the file to load from. |
| Offset | Optional. Specifies the file position from where the data is read. When not specified or set to zero the data is read from the beginning. |
| Format | Optional. Specifies a format identifier. When not specified Text Control assumes Text Control's internal format (3). Otherwise it can be one of the following values: |
| CurSelection | Optional. When set to true the loaded data replaces the current selection or is inserted at the current input position. The new input position is behind the inserted data. When omitted or set to false the loaded data replaces the complete control contents independent of the current selection. The new input position is at the beginning of the data. |

#### Format

| Constant | Description |
|---|---|
| 1 - ANSI text | Text in Windows ANSI format (an end of a paragraph is marked with the control characters 13 and 10). |
| 2 - TX text | Text in ANSI format (an end of a paragraph is marked only with the control character 10). |
| 3 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in ANSI. |
| 4 - HTML | HTML format (Hypertext Markup Language). |
| 5 - RTF | RTF format (Rich Text Format). |
| 6 - Unicode text | Text in Windows Unicode format (an end of a paragraph is marked with the control characters 13 and 10). |
| 7 - TX text | Text in Unicode format (an end of a paragraph is marked only with the control character 10). |
| 8 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in Unicode. |
| 9 - Microsoft Word 97-2003 | Microsoft Word 97-2003 format (\*.doc). |
| 10 - XML | XML format (Extensible Markup Language). |
| 11 - CSS | CSS format (Cascading Style Sheet). |
| 13 - Microsoft Word | Microsoft Word format (\*.docx). |
| 15 - SpreadsheetML | SpreadsheetML format (\*.xlsx). |

### Return Value

The method returns the position in the file after the data has been loaded.

### Data Types

| Name | Data type |
|---|---|
| FileName | String |
| Offset | Long |
| Format | Integer |
| CurSelection | Boolean |
| Return value | Long |

### Examples

This Basic example opens a file and loads its contents into TXTextControl1:

```vbscript
Private Sub mnuFile_Load_Click()
   On Error Resume Next
   ' Create an "Open File" dialog box
   CommonDialog1.Filter = "TX Demo (*.tx)|*.tx"
   CommonDialog1.DialogTitle = "Open"
   CommonDialog1.Flags = cdlOFNFileMustExist Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowOpen
   If Err Then Exit Sub
   ' Pass the filename to the text control
   TXTextControl1.Load CommonDialog1.filename
End Sub
```

### 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)
- [Programming Category: Loading, Saving and Database Support](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/load-save/llms-full.txt)

---

## Nearby

- **Previous:** [ListType Property](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/listtype-property/llms-full.txt)
- **Next:** [LoadDialog Method](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/loaddialog-method/llms-full.txt)
