Any way I can use Invoke Code or anything else to format the style of Excel Range?

Hello, I am pretty nice to UiPath and I was wondering if I can use the Invoke Code or anything else to change the format of the cells in my Excel file. (Fonts, Bold, Border, etc)
I set it up so it can bold and add the border to the last row and column. Because my code will create over 200 files and I need it to be in a specific format.
I really do want to avoid using Excel Application Scope btw. I want my code to work in the background.

Sub formatCell()

Dim ws As Worksheet: Set ws = ThisWorkbook.ActiveSheet
Dim lastRow As Long

lastRow = Cells(Rows.Count, 4).End(xlUp).Row

With ws.Range(ws.Cells(lastRow, 4), ws.Cells(lastRow, 10))
.Font.Bold = True
.Borders.LineStyle = xlContinuous
End With

End Sub

This is the code that I want to use. Is there any way to incorporate that in there?
Thank you.

hi @phiking ,

This can be Done via both Invoke VBA or Invoke Code.

Please refer the below videos -

⦿ Create VBA File in Excel
⦿ Edit VBA File in Excel
⦿ Debug VBA File in Excel
⦿ Refresh Multiple Pivots with the Help of Invoke VBA Activity UiPath

➤➤➤ This Video Demonstrates
⦿ How do we use the Invoke Code Activity in UiPath
⦿ How to use Loop inside the Invoke Code
⦿ Write Code to Delete Multiple Sheet with the help of Invoke Code


Mukesh

not sure about your usecase. alternatively a simpler method is to format an empty excel file properly,
whenever you run your bot, make a copy that excel file, then write the datatable to the file.