How to bold the header in Excel?

Hi,

Anyone can guide me on how to bold the header in Excel?

Thanks in advance!

@leewe01 use select range activity and give range than use send hot key activity by passing ctrl+b

2 Likes

hI @indra, do u have sample to Bold?I had tried as u mentioned above but seems not affected at all. Tq.

I’m having the same problem too. Anyone have any suggestion or knows the reason why sending hotkey ‘ctrl+b’ isn’t working?

Hi @Bonus
For easier appraoch, u can use invoke vba activity for this

it would be better apparach as it helps to invoke vba code to make headers bold

1 Like

I gave this a try and it worked. Thanks.

1 Like

Hi @NIVED_NAMBIAR ,

Can you please ping the invoke code here? So that I can try?

@kirankumar.mahanthi1 @Gokul001 @ppr

Hi @shreyash_shirbhate ,

try the below code. it will convert the font to bold for the specific range of headers. use invoke code activity and import microsft.office.interop.excel namespace. thanks.

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb1 = excel.Workbooks.Open(“Your Excel File Path”)
ws1 = CType(wb1.Sheets(“YourSheetName”), Microsoft.Office.Interop.Excel.Worksheet)
ws1.Range(“A1:J1”).Font.Bold=True
wb1.Save
wb1.Close
excel.Quit
ws1 = Nothing
wb1 = Nothing
excel = Nothing
GC.Collect

Hey @kirankumar.mahanthi1


I am getting this error.

Hi @shreyash_shirbhate

Try the below code

Private Sub FormatHeaders()
Dim A as Worksheet
For Each A in Worksheets
A.Activate
Cells.EntireColumn.Autofit
Cells.EntireRow.Autofit
Rows(“1:1”).Font.Bold = True
Next
Sheets(1).Select
End Sub

Regards
Gokul

What you can do is…

  • Use excel application scope and open the excel file.
  • In that use a read range to read the data so that you can get the number of rows…
  • use a for each row loop and loop through…
  • within the loop, have a variable that increments in each iteration. This variable can be used to identify the row number…
  • have a if condition to check whether the current row has the required value
  • if true, use select range activity and specify the range and highlight that row. You can use the variable we created to specify the range…
  • now use the hot key activity and pass the ctrl + B to change the font style yo bold

please refer to the original post
thanks

Hey @Gokul001,

where to give the path name here?

@Ahmad_Rais This is not the solution, I have already seen and tried it.

Thanks!

whats the problem when u try it ?,
maybe i can helps
thanks

Thanks @kirankumar.mahanthi1,

It is working now, We have to give the full path otherwise it will not work.

Thanks @Gokul001, appreciate your help man!

@Ahmad_Rais I have got the solution but for your knowledge the problem was occurring while sending the hotkey and it was not reflecting in the sheet.

okey thanks , what is the solution you get?

regards
ahmad

@Ahmad_Rais Please check @kirankumar.mahanthi1 post above!

thanks