Skip to main content

GetSelectedText

Returns the selected text from the document.

Syntax

expression.GetSelectedText(prop);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
propRequiredobjectThe resulting string display properties.
prop.NumberingRequiredbooleanDefines if the resulting string will include numbering or not.
prop.MathRequiredbooleanDefines if the resulting string will include mathematical expressions or not.
prop.TableCellSeparatorOptionalstring'\t'Defines how the table cell separator will be specified in the resulting string. Any symbol can be used. The default separator is "\t".
prop.TableRowSeparatorOptionalstring'\r\n'Defines how the table row separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r\n".
prop.ParaSeparatorOptionalstring'\r\n'Defines how the paragraph separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r\n".
prop.TabSymbolOptionalstring'\t'Defines how the tab will be specified in the resulting string. Any symbol can be used. The default symbol is "\t".
prop.NewLineSeparatorOptionalstring'\r'Defines how the line separator will be specified in the resulting string. Any symbol can be used. The default separator is "\r".

Returns

string

Example

function CorrectText () {
switch (window.Asc.plugin.info.editorType) {
case 'word':
case 'slide': {
window.Asc.plugin.executeMethod ("GetSelectedText", [{"Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9)}], function (data) {
sText = data;
ExecTypograf (sText);
});
break;
}
case 'cell': {
window.Asc.plugin.executeMethod ("GetSelectedText", [{"Numbering": false, "Math": false, "TableCellSeparator": '\n', "ParaSeparator": '\n', "TabSymbol": String.fromCharCode(9)}], function (data) {
if (data == '') {
sText = sText.replace (/\t/g, '\n');
ExecTypograf (sText);
}
else {
sText = data;
ExecTypograf (sText);
}
});
break;
}
}
}