locked
Excel Automation - Mix text, bold and not bold on the same cell RRS feed

  • Question

  • Am trying to send text to Excel, to a specific cell, but I need to have a mix of bold and not bold text on it. How can I do it?

    i.e. Cell A1:     This text is BOLD

    I need it to be in the same cell

    • Edited by Benny Gabel Thursday, February 28, 2019 3:44 PM
    Thursday, February 28, 2019 3:42 PM

Answers

  • I found it

    lo_excel = CREATEOBJECT("Excel.Application")
    *- Create an excel application
    lo_Workbook = lo_excel.Workbooks.Add()
    
    lo_Excel.range("A1").Value = "This is a bold statement"
    
    ln_Start = 11
    ln_End   = 4
    lo_ActiveCell = lo_excel.Range("A1")
    lo_ActiveCell.Characters(ln_Start, ln_End).Font.Bold = .t.
    

    • Marked as answer by Benny Gabel Thursday, February 28, 2019 5:32 PM
    Thursday, February 28, 2019 5:32 PM

All replies

  • I found it

    lo_excel = CREATEOBJECT("Excel.Application")
    *- Create an excel application
    lo_Workbook = lo_excel.Workbooks.Add()
    
    lo_Excel.range("A1").Value = "This is a bold statement"
    
    ln_Start = 11
    ln_End   = 4
    lo_ActiveCell = lo_excel.Range("A1")
    lo_ActiveCell.Characters(ln_Start, ln_End).Font.Bold = .t.
    

    • Marked as answer by Benny Gabel Thursday, February 28, 2019 5:32 PM
    Thursday, February 28, 2019 5:32 PM
  • Hi,

    I am glad you have got your solution and shared us your solution.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 1, 2019 1:21 AM