All docs
V21.2
21.2
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ActiveX Controls in Rich Text Documents

  • 2 minutes to read

The WPF Rich Text Editor allows you view, print, and export documents with ActiveX controls to PDF. You can retrieve ActiveX controls from a document, obtain control properties, or delete these controls.

Important

The Rich Text Editor displays ActiveX controls as images. You cannot run macros associated with ActiveX controls.

Supported Formats

The WPF Rich Text Editor supports ActiveX controls in following file formats:

  • DOCX
  • DOCM
  • DOC
  • DOT
  • DOTX
  • DOTM
  • RTF
  • PDF (export only)

If a DOC file is encrypted, the Rich Text Editor loads and saves ActiveX controls as images.

Access ActiveX Controls

ActiveX controls are stored in ShapeCollection returned by the SubDocument.Shapes property. Use the ShapeCollection.Item property to return an individual control (a Shape object) from the collection. The Shape.Type property helps you determine a drawing object type. This property returns the ActiveXControl value for an ActiveX control.

The Shape.ActiveXFormat property allows you to obtain the following ActiveX control properties:

Property Description
Name Returns the control’s name.
ControlType Returns the control’s type.
ProgId Returns the programmatic identifier associated with the control.

The following example retrieves all text box controls from the document:

using DevExpress.XtraRichEdit.API.Native;
using System.Linq;
// ...

Document document = richEditControl.Document;
List<Shape> textBoxes = document.Shapes
.Where(x => x.Type == ShapeType.ActiveXControl && 
x.ActiveXFormat.ControlType == ActiveXControlType.TextBox)
.ToList();

Remove ActiveX Controls

Use one of the following methods to remove an ActiveX control from the document:

The following example removes all ActiveX controls from the collection:

Document document = richEditControl.Document;
ShapeCollection shapes = document.Shapes;
for (int i = shapes.Count - 1; i >= 0; i--)
{
    if (shapes[i].Type == ShapeType.ActiveXControl)
        shapes.Remove(shapes[i]);
}
See Also