Free Support Forum - aspose.com

{ MERGEFIELD Hyperlink:name }

Hi

I am trying to merge a hyperlink:

{ MERGEFIELD Hyperlink:name }

But i get this error:

Start and end node should have the same grand parent.

Lucifer

Hi,

Thank you for considering Aspose.Words. Sorry but I cannot understand what you want to achieve. Please post your code here and attach the document template. Also, provide more details of your task.

Hi

Sorry for being vague.

I get the error when merging the first bit of data into my word doc.

I have this code to handle the image and other fields being merged.

Private Sub MergeProductsPage()

MergeHeaderAndFooter(_productsDoc)

_currentDocBuilder = New DocumentBuilder(_productsDoc)

AddHandler _productsDoc.MailMerge.MergeImageField, AddressOf HandleMergeProductImages

AddHandler _productsDoc.MailMerge.MergeField, AddressOf HandleMergeProductFields

_productsDoc.MailMerge.Execute(CreateProductTable)

End Sub

Private Sub HandleMergeProductImages(ByVal sender As Object, ByVal e As MergeImageFieldEventArgs)

If e.FieldValue Is String.Empty Then

Exit Sub

End If

Select Case e.FieldName

Case "ProductImage"

_currentDocBuilder.MoveToMergeField(e.FieldName)

_currentDocBuilder.InsertImage(e.FieldValue, 120, 150)

End Select

End Sub

Private Sub HandleMergeProductFields(ByVal sender As Object, ByVal e As MergeFieldEventArgs)

If e.FieldValue Is String.Empty Then

Exit Sub

End If

Select Case e.FieldName

Case "ProductUrl"

_currentDocBuilder.MoveToMergeField(e.FieldName)

_currentDocBuilder.InsertHyperlink("Click for information or to buy", e.FieldValue, False)

End Select

End Sub

Hi,

First of all, avoid using semicolon for simple merge fields, use it for region markers or image placeholders only. So rename Hyperlink:XXX to something else. However, this won't help because the ProductUrl field (placed below) still throws. I'm not sure what the cause is, probably the document is corrupted. Try to remake it if possible. Meanwhile I have logged the issue as #1490 in our defect database.

I've checked this on Aspose.Words 4.4.2 and it works fine. MoveToMergeField("ProductUrl") works fine. So I'm closing the defect.

Do you still have any questions? Are you still using Aspose.Words and happy with it?