NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
697 stars 143 forks source link

NetOffice.WordApi wdFieldFormTextInput truncates over 255 characters #294

Closed pattyk13 closed 4 years ago

pattyk13 commented 4 years ago

Hello,

I recently switched from interop to NetOfficeFw in hopes that it would have fixed some of the limitations in creating a word document. I have this code:

        Word.FormField formField = document.FormFields.Add(range, Word.Enums.WdFieldType.wdFieldFormTextInput);

        formField.TextInput.Default = defaultText;
        formField.TextInput.EditType(Word.Enums.WdTextFormFieldType.wdRegularText);

It works great except of the defaultText is over 255 characters, and then it truncations to 255.

Thanks in advance.

jozefizso commented 4 years ago

Hi @pattyk13, does this truncation occur when you use the Interop directly?

jozefizso commented 4 years ago

API Reference

FormField.TextInput property (Word)
TextInput.Default property (Word)

TextInput.Default property returns or sets the text that represents the default text box contents. Read/write String.

jozefizso commented 4 years ago

When I enter the default text value in the Text Form Field Options dialog, it is truncated to the 255 characters.

Entered value: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dapibus tincidunt sapien ac varius. Proin egestas erat nec fermentum pretium. Nunc id nisi non diam imperdiet venenatis. Suspendisse iaculis massa sit amet imperdiet dictum. Morbi suscipit est non risus cursus, porta sagittis mi augue. (300 characters)

Accepted value: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dapibus tincidunt sapien ac varius. Proin egestas erat nec fermentum pretium. Nunc id nisi non diam imperdiet venenatis. Suspendisse iaculis massa sit amet imperdiet dictum. Morbi suscipit e (255 charaters)

image

jozefizso commented 4 years ago

This is behavior of Microsoft Word. It is limiting the TextInput.Default value to 255 characters.

pattyk13 commented 4 years ago

Yes.

On Fri, Sep 4, 2020 at 9:26 AM Jozef Izso notifications@github.com wrote:

Hi @pattyk13 https://github.com/pattyk13, does this truncation occur when you use the Interop directly?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NetOfficeFw/NetOffice/issues/294#issuecomment-687251745, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ35AL4K5UE5WCPYGXTPCLLSEEILFANCNFSM4QY2H6JA .