How to bold header in file excel by processed from Uipath?

This sample data:

This data was not previously in the project folder, but it appears after the process has successfully run.

For example header to be:
image

for activity in Project

2 Likes

Hi @bayu.herlambang

Use the below Macros code to make A1:F1 bold. Place the Invoke VBA acitvity after the first Set Range Color activity:

Sub BoldHeaders()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet's name
    
    With ws.Range("A1:F1").Font
        .Bold = True
    End With
End Sub

Properties of Invoke VBA

Text file path:
Macos Code.txt (211 Bytes)

Hope it helps!!

2 Likes

when run there is an error as below

1 Like

Hi @bayu.herlambang

Make sure that Macros is enabled. If not follow the below steps from the thread.

Regards

1 Like

After uodate VBA Marcos
Uploading: image.png…

1 Like

Hi @bayu.herlambang

I’m sorry that I’m not able to see the screenshot. Make sure to pass the sheet name that you have in your excel and you are good to go.

Regards

1 Like

@bayu.herlambang

Whynot simply use a blank template with headers

So that you can just write the data and everything looks as you need

Cheers

1 Like

@bayu.herlambang ,

You can use Invoke code approach which don’t have dependency on Macro settings which most of the organizations are scared of to enable.

Make sure you import the necessary namespaces at the beginning of your file:

Imports Microsoft.Office.Interop.Excel

Use this code in Invoke Code activity

Dim excelApp As Microsoft.Office.Interop.Excel.Application
Dim workbook As Microsoft.Office.Interop.Excel.Workbook
Dim worksheet As Microsoft.Office.Interop.Excel.Worksheet

excelApp = New Microsoft.Office.Interop.Excel.ApplicationClass()
workbook = excelApp.Workbooks.Open("your_excel_file_path.xlsx")
worksheet = workbook.Sheets("Sheet1") ' Replace "Sheet1" with your sheet name

Dim headerRange As Microsoft.Office.Interop.Excel.Range
headerRange = worksheet.Rows(1)
headerRange.Font.Bold = True

workbook.Save()
workbook.Close()
excelApp.Quit()

Thanks,
Ashok :slight_smile:

2 Likes

Thanks,
Done
image

2 Likes

You’re welcome @bayu.herlambang

Happy Automation!!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.