How to set excel cell font bold

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
yadhukrishna36
Newbie
Posts: 13
Joined: Tue Oct 06, 2020 6:28 pm

How to set excel cell font bold

Post by yadhukrishna36 » Fri Jan 22, 2021 7:19 am

Hi I want to set the font of a specific cell range in the excel sheet to BOLD
I tried

Code: Select all

 
  VBStart
      Sub setExcelCellBold(vbFilePath)
        Set objExcel=CreateObject("Excel.Application")
    	  objExcel.Visible = false
        Set objWorkbook = objExcel.Workbooks.Open(vbFilePath)
        Set objRange = objExcel.Range("CB3","CD3")
        objRange.Font.Bold = TRUE
        objWorkbook.Save
        objWorkbook.Close
        objExcel.Quit
      End Sub
    VBEND
    
    Let>filePath=C:\Users\Radesh\Desktop\fontBoldTest.xlsx
    VBRun>setExcelCellBold,%filePath%
It's working but I would like to use macro scheduler functions like

XLSetRangeFormat>xlbook,%sheet%,A1,Font.Bold=True :lol:
Thanks in advance

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to set excel cell font bold

Post by Dorian (MJT support) » Fri Jan 22, 2021 9:58 am

As of Macro Scheduler Version 15.0.02 19/02/2020. Not available in Lite.

For this you need XLRunCode. It can be used to run a single line of code or an entire block of code (samples are in the linked help file).

Code: Select all

XLopen>d:\output.xlsx,1,xlH
XLRunCode>xlH,ActiveSheet.Range("CB3:CD3").Font.Bold = True
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How to set excel cell font bold

Post by Dorian (MJT support) » Fri Jan 22, 2021 10:12 am

As an afterthought to help you in future... this article shows how to generate vba for use with XLRunCode.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts