# Convert

Converts a document to text, RTF, or HTML format.

Before you convert a document, you must open it by using the Open method. To make sure that the entire document is opened before the document is converted, set the OPENWaitOnOpen property to `TRUE`. Use the CanSaveAs property to check whether the document is completely processed and is ready for conversion.

To convert a document without viewing it, set the OPENMode property to `2` (open without generating a view).

## Syntax

    bRet = KeyView.Convert(FormatCode, TargetFile)

## Parameters

Parameter | Type | Description
--- | --- | ---
`FormatCode` | String | The format code of the format to which to convert the document. The following options are available: `txt` — conversion to text format `rtf` — conversion to RTF format `htm` — conversion to HTML format
`TargetFile` | String | The target path and file name for the converted file.

## Returns

Type | Description
--- | ---
Boolean | `TRUE` if the method succeeds. `FALSE` if the method fails.

## Example

The following code converts a file to RTF:

    Function ConvertToRTF(FileName As String, TargetFile As String) As Boolean

    KeyView.OPENMode = 2

        nRet = KeyView.Open(FileName)

        If (nRet = 1) Then

            bRet = KeyView.Convert("rtf",TargetFile)

        End If

        bRet2 = KeyView.Close

        ConvertToRTF = bRet

    End Function

In this example, `OPENMode` is set to `2` to prevent a view of the document.

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm