简体   繁体   中英

How to identify a date Word FormField?

I'm working on a C# application that loads a Word document and tries to extract all FormFields (or bookmarks).

Using the following line of code...

wd.FormFields.get_Item(ref index).Type

I have no problem identifying a checkbox which returns wdFieldFormCheckBox or a drop-down list which returns wdFieldFormDropDown. When it comes to date fields I simply get wdFieldFormTextInput. This makes it indistinguishable from a regular text input field which also returns wdFieldFormTextInput. I need to be able to tell whether the input field is a date & time field or a date field or simply a time field. Is it possible to identify a date field?

Thanks!

You ask:

Is it possible to identify a date field?

... and yes, it is. If you take a look at the documentation for the WdFieldType enum (which is the type of the FormField.Type property you use in your sample) you will see that it can have values like wdFieldTime and wdFieldDate - so yes, it should definitely be possible to identify a such field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM