Forum Discussion

hyper111's avatar
hyper111
Contributor
11 years ago

Writing to Excel two colored words.

Hi, I would like to know is it possible to write to cell two colored word ? ex. WO (red) RD (black) Thanks,
  • googleid_118035's avatar
    11 years ago
    Hi Paul,



    Now we have an Excel file with an above macro which will format letter in row number 10 and cloumn number 4.



    We will create following scripts in Testcomplete using VB scripts.

    Which will write letter "WORD" into the file and run the text format macro.




    Sub Test1()


    Call Insert_Val("C:\Dev_Chaminda\Book1.xls", "Sheet6", 4, 10, "WORD")


    Call Open_Excel_File("C:\Dev_Chaminda\Book1.xls", oExcel, oBook)


    macro_name1   = "Macro1"


    oExcel.Run(oBook.Name & "!" + macro_name1)


    oBook.Close True


    oExcel.Quit


    End Sub


    Function Insert_Val(file, sheet, x, y, textval)


    Set b = CreateObject("Excel.Application")


    b.DisplayAlerts = False


    Set c = b.Workbooks.Open(file)


    c.Worksheets(sheet).Cells(y, x).Value = textval 


    c.Save


    c.Close True 


    b.Quit


    End Function


    Function Open_Excel_File(App, oExcel, oBook)


    Set oExcel = CreateObject("Excel.Application")


    oExcel.DisplayAlerts = False  


    Set oBook = oExcel.Workbooks.Open(App)


    End Function