How to add border to Excel rows



Hi, I’m trying to add a border to a particular range in excel while writing them. I’m quite new to Uipath and C#. I managed to find the below resource, but I’m not quite sure how I can apply this logic in UiPath.

How can a border be set around multiple cells in excel using C#.

Please guide me.

Thank you


Please read this,


I know, That’s why I attached the resource stating how we can assign the border in Excel using C#.

Here is the link:

How can a border be set around multiple cells in excel using C#.

Any Ideas how can I incorporate it into my flow?


Please download both files(xaml and macro file),
Excel save.xaml (8.3 KB)Set Border.xlsx (9.0 KB)

save Set Border.xlsx file as Set Border.xlsm
and run.


hi, when I’m opening Set Border after changing its extension I’m getting an error saying file may be corrupted.


Ok… No worries.

  1. please create excel as *.xlsm,
  2. go to developer tab,
  3. click on macros and create new macro and
  4. Paste below code, save it and run it

Sub setBorder()
Dim rang As Range
Set rang = Worksheets(“Sheet1”).Range(“A1:B4”)
With rang.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
End Sub



Hello @Pankaj.Patil,
thank you, But what if we aren’t allowed to run the macro on the target machine? I want something that can be written like set colour activity for cell or range.

Any guesses there?

Thanks :slight_smile:


Hello @RishiVC1,

It’s enough simple. please download xaml and excel files below,
Report.xlsx (7.8 KB)
Main.xaml (7.3 KB)



what I meant that there should be an equivalent solution for setting up borders as compared to setting colour.