EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
261 stars 47 forks source link

ContentControls.Add() is trimming space from user selection #217

Closed achandroth001 closed 2 months ago

achandroth001 commented 3 months ago

I am trying to select some text and add a content control to this selected text as below.

selection.Range.ContentControls.Add(WdContentControlType.wdContentControlText);

This is trimming out the preceeding space from the selection. Thus converting only the part of the text excluding the trailing space into a control.

How do I achieve this without tampering the existing selected text. With some of the solutions I tried the existing control within the selection is getting removed.

PrzemyslawKlys commented 3 months ago

Hi, I'm pretty sure this is not from OfficeIMO as I haven't added anything around ContentControls. Is it part of OpenXML SDK maybe?