Hi all,
In a document I have a DocVariable, its value a text, thats represents a route, and I need to turn it into Hyperlink, I don’t know how to do it.
And I have another question, in another DocVariable with a text value, I need to put in bold only some words, is possible to do it?
I’m doing all with VB.NET
.
Thanks
Jonathan Prieto
Hi Jonathan,
Thank you for your inquiry. If you would like to replace DocVariable field with Hyperlink field, then I think, you should use the same technique as shown in the following thread:
https://forum.aspose.com/t/95984
The code provided there replaces REF fields with HYPERLINK fields.
Regarding formatting, Each field in MS Word consists of FieldStart node, field code, FieldSeparator node, field value (displayed text) and FieldEnd node. So if you would like to change formatting of some text within field value, you should split Run that represents field value and change its formatting. I think the code provided in the following article could be useful for you:
https://docs.aspose.com/words/net/find-and-replace/
Best regards.
Hi Alexey, thanks for your answer,
I have been trying, but I think I can’t do it of that way, because the DocVariables for replace are in differents cells of a table, and I can’t do this:
objbuilder.MoveTo([row.Cells(i)])
Its generate an error: Run-time exception thrown : Aspose.Words.PleaseReportException - Exception ‘The node must be a paragraph or a direct child of a paragraph.’
I don’t have any idea…I’m lost
Hi
Thanks for your request. Maybe you should try using the following code:
objbuilder.MoveTo(row.Cells(i).FirstParagraph)
Hope this helps.
Best regards.
Thanks Alexey, it works!!
Now, another cuestion about a DocVariable: can i delete one? i need remove the DocVariable from the document, the element, not the value. This method is for remove the value of DocVariable, not the element.
pobjWordDocument.Variables.Item(“DocVariable”).Remove
Thanks again!!
Hi
Thanks for your inquiry. I think you should remove DOCVARIEBLE fields from your document. Each field in MS Word consists of FieldStart node, field code, FieldSeparator node, field value (displayed text) and FieldEnd node. So if you would like to remove field you should remove all these nodes. Please let me know if you need more assistance, I will be glad to help you. Also, please attach your document here for testing.
Best regards.