# Using Images

> Insert images anchored, as a character or fixed with ImageInsert, embed or link image data, and open the Image Attributes dialog with ObjectAttrDialog in VB6.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control ActiveX > Document Editor > Using Images
- **1595 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/images/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/images/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/images/llms-full.txt

---

Logos, photos and icons go into a `TXTextControl` document as images, which flow with a paragraph, sit in a line like a character or stay at a fixed place on the page. You choose the placement with the method that inserts the image, and you decide how image data is stored when the document is saved.

![The TXWords sample with the TX Text Control logo as an image at the top of the document, selected with a dashed frame, in the look of TX Text Control 10](https://docs.textcontrol.com/assets/img/tx-text-control-activex/document-logo-selected.c7be63dd.webp)

The Visual Basic 6 samples below come from the *Samples\\vb6\\Images* sample source directory. They open a file dialog box to insert an image and open the built-in dialog box for its attributes.

### How Images Are Placed

TX Text Control has three methods for inserting images:

| Method | Placement | Typical use |
|---|---|---|
| [ImageInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/imageinsert-method/llms-full.txt) | Anchored to a paragraph. Text can flow around the image, and the image moves with the paragraph. | The default method for inserting images |
| [ImageInsertAsChar](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/imageinsertaschar-method/llms-full.txt) | Handled like a single character in the text | Small images and icons |
| [ImageInsertFixed](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/imageinsertfixed-method/llms-full.txt) | At a fixed position on the page. The image keeps its position regardless of the surrounding text. | Images that must not move with the text |

![An image selected in a TXTextControl of version 34.0, with sizing handles and an anchor symbol in the margin next to the paragraph it is anchored to.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/image-selected-anchor.bbdd2944.webp)

### How Image Data Is Loaded and Saved

Images are inserted from a file or from the clipboard. When you save a document, you choose whether the image data is embedded in the document file or the document holds a reference to a separate image file. Not every option is available in every file format: RTF, DOCX and DOC files can embed image data, and HTML can't.

Further options are:

- converting images to a different file format;
- converting embedded images to image files;
- changing the image resolution and the compression rate.

These options matter when you create HTML files, in which embedded images and image file formats such as WMF or TIFF have to be converted to JPEG or GIF files so that a browser can display them. Resolution and compression settings are also needed for PDF files, for instance to create one version of a PDF file with low-resolution images for viewing on screen and another one with high-resolution images for printing.

### Insert an Image From a File

The `mnuImage_Insert_Click` procedure of the sample opens a dialog box in which the user selects an image file, and then inserts the image:

```vbscript
Private Sub mnuImage_Insert_Click()
    On Error GoTo err_InsertImage

    CmDialog1.DialogTitle = "Insert Image"
    CmDialog1.Filter = TXTextControl1.ImageFilters
    CmDialog1.FileName = ""
    CmDialog1.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt Or cdlOFNHideReadOnly
    CmDialog1.CancelError = True
    CmDialog1.ShowOpen

    TXTextControl1.ImageInsert CmDialog1.FileName, -1, 1, 0, 0, 100, 100, 3, 100, 100, 100, 100
    Exit Sub

err_InsertImage:
    If Err <> cdlCancel Then MsgBox Err.Description

End Sub
```

The code works as follows:

- [ImageFilters](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/imagefilters-property/llms-full.txt) returns the available image filters as a string that initializes the `Filter` property of the Common Dialog control `CmDialog1`.
- With `CancelError` set to `True`, canceling the dialog box ends in the error handler `err_InsertImage`, which shows a message for every error other than `cdlCancel`.
- [ImageInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/imageinsert-method/llms-full.txt) inserts the selected file anchored to the paragraph at the current input position (`-1`), left aligned (`1`), at 100 percent in both directions, with the text flowing around it (`3`) and a distance of 100 twips to the text on each side.

### Set Image Attributes

TX Text Control has a built-in dialog box in which the user changes the size of an image, the way it is stored and other settings. In the sample, the **Image Settings** menu item opens the **Image Attributes** dialog box, and so does a right-click on an image. Both call the [ObjectAttrDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/objectattrdialog-method/llms-full.txt) method:

```vbscript
Private Sub mnuImage_Settings_Click()
    TXTextControl1.ObjectAttrDialog
End Sub

Private Sub TXTextControl1_ObjectRightClicked(ByVal ObjectId As Integer)
    TXTextControl1.ObjectAttrDialog
End Sub
```

The code works as follows:

- `mnuImage_Settings_Click` handles the **Image Settings** menu item.
- [ObjectRightClicked](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/objectrightclicked-event/llms-full.txt) occurs when an object has been clicked with the right mouse button, and passes its identifier in `ObjectId`.

![The Size and Distance tab of the built-in Image Attributes dialog box of TX Text Control ActiveX 34.0, with the height and width, the scale, the distances from the text and the mouse options.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/image-attributes-size.1c4ac6ab.webp)

![The Saving Options tab of the built-in Image Attributes dialog box of TX Text Control ActiveX 34.0, with the saving style, the file name and type, the resolution and the compression quality.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/image-attributes-saving.a07ac7aa.webp)

### Find the Members for Images

The programming category [Images, Text Frames, Signature Fields and OLE Objects](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/images-objects/llms-full.txt) lists all properties, methods and events for images. Members whose names begin with "Object" work with images and with the other kinds of embedded objects, such as text frames and OLE objects. Members whose names begin with "Image" apply to images only.

### Next Steps

- [Using Text Frames](https://docs.textcontrol.com/tx-text-control-activex/document-editor/text-frames/llms-full.txt): inserting text frames, which share the "Object" members with images.
- [Working with Files](https://docs.textcontrol.com/tx-text-control-activex/document-editor/load-save/llms-full.txt): loading and saving documents.
- [Images, Text Frames, Signature Fields and OLE Objects](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/images-objects/llms-full.txt): all members for images and other objects.

---

## Nearby

- **Previous:** [Number Formats](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/number-formats/llms-full.txt)
- **Next:** [Using Text Frames](https://docs.textcontrol.com/tx-text-control-activex/document-editor/text-frames/llms-full.txt)
