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

Free Support Forum - aspose.com

Find and replace in hyperlinks -> is helper class needed anymore?

Hi Aspose team,

Over http://www.aspose.com/docs/display/wordsnet/How+to++Replace+or+Modify+Hyperlinks you are writing (last update 7th of April):

"To find and modify hyperlinks it would be nice to have some sort of Hyperlink object with properties, but in the current version, there is no built-in functionality in Aspose.Words to deal with hyperlink fields.

While Aspose.Words does not have a high-level abstraction to represent fields and hyperlink fields in particular, all of the necessary low-level document elements and their properties are exposed and with a bit of coding you can implement quite sophisticated document manipulation features."

but recently I saw that if I use coding like:


Dim hyperlink As FieldHyperlink

If fld.Type.Equals(FieldType.FieldHyperlink) Then

For Each fld In officeDocument.Range.Fields

hyperlink = fld

next

end if


I have properties like Address, SubAddress, Target...

Does that mean that we can skip helper class now?

Thanks,
Oliver

Hi Oliver,

Thanks for your inquiry. FieldHyperlink class implements the HYPERLINK field. Yes, you can skip Hyperlink helper class. We will update the documentation according to new API changes. We suggest you please read following public API changes.
Public API Changes in Aspose.Words 15.1.0

Please check following code example for your kind reference. Hope this helps you.

string NewUrl = @"http://www.aspose.com";

string NewName = "Aspose - The .NET & Java Component Publisher";

Document doc = new Document(MyDir + "in.docx");

foreach (Field field in doc.Range.Fields)

{

if (field.Type == FieldType.FieldHyperlink)

{

FieldHyperlink hyperlink = (FieldHyperlink)field;

// Some hyperlinks can be local (links to bookmarks inside the document), ignore these.

if (hyperlink.SubAddress != null)

continue;

hyperlink.Address = NewUrl;

hyperlink.Result = NewName;

}

}

doc.Save(MyDir + "Out.docx");