Free Support Forum - aspose.com

Insert>Field...>Date Field (format "MMMM d- yyyy")

Hi,

I have a problem. I created a word document where I used the “Insert” menu and selected “Field” and further selected format “MMMM d, yyyy”. The result is current date in what may look like a formfield but it is not. Save the document as .doc.

I am having trouble reading the date that is in that field. I get the following from .NET debugger:

doc.Range.Bookmarks[oBookmark.ToString()]
{Aspose.Word.Bookmark}
System.Object: {Aspose.Word.Bookmark}
a: {Aspose.Word.Model.aa}
b: null
Name: “Date”
Text: “ DATE @ “MMMM d, yyyy” March 7, 2005”
BookmarkStart: {Aspose.Word.Model.aa}
BookmarkEnd: {Aspose.Word.Model.l}

I am sorry if I wasn’t clear enough. When I programmatically open said document and try to obtain the Datefield contents I get “ DATE @ “MMMM d, yyyy” March 7, 2005”, which isn’t what I want. Is there any way in which I can obtain the desired information (“March 7, 2005”) from such a field using Aspose.Word?

Hi,
At the moment the only way to obtain this information from the DATE field is parsing the string you get. Current date is placed between field separator ((char) 20) and field end (char (21)) characters. So simply extract current date from the string.

Parsing like you recommended works. Thanks for the prompt response. But do you plan to make retrieval from such (non-merge/non-form) fields easier in the future? (I sure hope soBig Smile)

I also have another issue:
http://www.aspose.com/forums/ShowPost.aspx?PostID=16178

Thanks again for resolving my problem.

Yes, we’ll implement this in the future, but now it is difficult to say when exactly.