We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merge field capability with Aspose Words

Hi,

I am trying to insert fields into new/existing documents using Aspose Editor. Editor currently does not have the functionality to do this. The post below says "But you may accomplish this, except Microsoft Word macros, using Aspose.Words and then load WordML stream into the editor."

Can you explain what this means? And also help me understand how to create(insert) a merge field(s) using Aspose Words.

<A href="</A></P> <P>thanks,</P> <P>archana</P>

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. This means that you can insert bookmark or mergefield using Aspose.Words and then load the updated document into Aspose.Editor.

You can insert bookmark into the document using InsertBookmark method. See the following link to learn more:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/inserting-a-bookmark.html

You can insert mergefield using InsertField method:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/inserting-a-field.html

Hope this helps.

Best regards.

Hi,

How can you load a document of type Aspose.Words.Document in to Aspose.Editor which expects a document of type Aspose.Editor.Desktop.Document?

Can you please provide me with a VB sample of the following:

"insert mergefield using Aspose.Words and then load the updated document into Aspose.Editor."

thanks,

archana<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Here is VB code that you can use:

'Open existing document using Aspose.Words

Dim doc As Aspose.Words.Document = New Aspose.Words.Document("C:\Temp\in.doc")

'Create DocumentBuilder

Dim builder As Aspose.Words.DocumentBuilder = New Aspose.Words.DocumentBuilder(doc)

'Move cursor to the end of document

'You also can move cursor to any place in the document using MoveToXXX method

builder.MoveToDocumentEnd()

'Insert mergefield into the document

builder.InsertField("MERGEFIELD MyFieldName \* MERGEFORMAT", "┬źMyFieldName┬╗")

'Save the document into the stream

Dim awDocStream As New System.IO.MemoryStream()

doc.Save(awDocStream, Aspose.Words.SaveFormat.WordML)

'Set current position of Stream 0 (begining of stream)

awDocStream.Seek(0, IO.SeekOrigin.Begin)

'Load document into the Editor control

EditorControl1.Open(awDocStream)

But note that Aspose.Editor shows fields as red crosses. Red crosses are the marks for unknown (for current version) document items. You can read about this here: http://www.aspose.com/documentation/visual-components/aspose.editor-for-.net/lossless-editing.html

Current version of Aspose.Editor treats images and fields as unknown items.

Best regards.