Hello, dear friends!
I need to break links in a workbook. When I use Excel Application Scope, the “break link” button does not work. When I do it manually, the button works. What to do?разрыв связей.xaml (28.5 KB)
Hi @Ayzhana,
Welcome to UiPath Forum Community.
.
In Balareva.Excel.Activities has an activity called Hyperlink Remove. Using this you can able to remove the hyperlink to the cells.
Regards
Balamurugan.S
There was an error… Hyperlink Remove: Exception from HRESULT: 0x800A03EC
let me check and get back to you…
well, I’ll wait
I managed to do so using invoke code. Been trying to do so in VB without success, finally managed to do it in C#. VB gives an error that it cannot cast xlWb.LinkSources(xlExcelLinks) to an array, it will only recognize it as an object, so you will not be able to iterate it in a for loop unlike what you see in C#. Below is the code I came up with after doing a lot of research (I’m new to C#). The only input argument you will require is FilePath.
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook xlWb;
try{
xlApp.DisplayAlerts= false;
xlWb = xlApp.Workbooks.Open(FilePath);
Array olinks = xlWb.LinkSources(Microsoft.Office.Interop.Excel.XlLink.xlExcelLinks) as Array;
if (olinks != null)
{
for (int i = 1; i <= olinks.Length; i++)
{
xlWb.BreakLink((string)olinks.GetValue(i), Microsoft.Office.Interop.Excel.XlLinkType.xlLinkTypeExcelLinks);
}
}
xlWb.Save();
xlWb.Close();
}
catch (System.Exception MyEx){
throw myEx;
}
finally{
xlApp.DisplayAlerts = true;
xlApp.Quit();
}