Color excel cells without Excel Application Scope

Hi UI Path community. I am looking for a way to color excel cells without using excel application scope due to a computer not having Excel. I have already searched for possible solution and found this one presented by @etss1016 :
"You can invoke the code to set color for cell like below.

Dim xlApp As Microsoft.Office.Interop.Excel._Application = Nothing
Dim xlWorkBooks As Microsoft.Office.Interop.Excel.Workbooks = Nothing
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook = Nothing
Dim xlWorkSheet1 As Microsoft.Office.Interop.Excel.Worksheet = Nothing

xlWorkSheet1= CType(xlWorkSheets(1),Microsoft.Office.Interop.Excel.Worksheet)
xlWorkSheet1.Range(“A1:A2”).Interior.ColorIndex = 40 "
However, I do not understand how to apply it. Where to define file name and other details. Can someone help me to explain this solution or infrom me about another one?

Heyy @dias97

Here is the code

    Dim excel As Microsoft.Office.Interop.Excel.Application
    Dim wb As Microsoft.Office.Interop.Excel.Workbook
    Dim ws As Microsoft.Office.Interop.Excel.Worksheet
    excel = New Microsoft.Office.Interop.Excel.Application

    wb = excel.Workbooks.Open("C:\Input\inputdata.xlsx", [ReadOnly]:=False)
    excel.Visible = True

    ws = CType(wb.Sheets("Summary"), Microsoft.Office.Interop.Excel.Worksheet)
  ws.Range("A2:A6").Interior.Color = RGB(255, 255, 255)

Thank you for your answer, I will try it :slight_smile:

Thank you, it worked. Appreciate your help!

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