Coloring Text in Excel File

Hi Team,

I am working on collections and i want to change the text of the font to some particular columns.
How can i achieve it.

Regards,
Sree
 

VJR

Well-Known Member
Hi bharadwaj813,

Refer the section 'How to set the FillColor to a cell:' in the below link.
http://rpaforum.net/threads/excel-cell-color-identification.1039/post-3087

The above link is for Fill Color.
For Font color the only difference is to use the below line of code instead.

Code:
GetWorkbook(handle,Nothing).ActiveSheet.Range(cellref,cellref).Font.Color = RGB(Red_Value, Green_Value, Blue_Value)

In the above case you need to separately pass the columns with a new Action stage.
eg; A:B
Then again a new Action stage for D column.

But if you want to have a single stage and pass all the required columns at once then use the below line of code

GetWorkbook(handle,Nothing).ActiveSheet.Range(cellref).Font.Color = RGB(Red_Value, Green_Value, Blue_Value)

Now you can pass multiple consecutive or non consecutive columns as below.

1527620309081.png

and only A, B and D columns will have the new Font color.

1527620353008.png

You can also pass row numbers.
For example; when you pass Cell Reference parameter as below,
1527620705495.png

then the result will be as below.
1527620501511.png
 
Last edited:

VJR

Well-Known Member
Hi arunkiran,

You are right. There is no such action in the MS Excel VBO. For that purpose you need to follow instructions mentioned in the below post on how to proceed for creating a new custom VBO to set the Font color.
For eg; the below post says to make a copy of the existing 'Format Cell' action of the MS Excel VBO
Then the instructions on how to give the RGB colors are also explained in the below post. And then what kind of input and output parameters are to be used are also shown in the below post.
http://rpaforum.net/threads/excel-cell-color-identification.1039/#post-3087
The only difference is use the line of code shown above in this current thread.
 

deepika

New Member
Hi,

I am using the above mentioned code for coloring text in excel but I am getting the below error:

Internal : Could not execute code stage: Object of type 'System.String' cannot be converted to type 'System.Data.DataTable'.
 

yeturirpa

New Member
Hi VJR,

I have tried your approach to format excel cell values but am unable to run the code stage. it's throwing an exception saying: the given key was not present in the dictionary.

please Find the attachment.
 

Attachments

  • Error.PNG
    14.6 KB · Views: 88

dsmith616

New Member
Same here. Attempting to use provided code but it appears to be missing elements in order to execute via Blue Prism. My object shows 5 errors related to the code added.
 

dsmith616

New Member
Hi bharadwaj813,

Refer the section 'How to set the FillColor to a cell:' in the below link.
http://rpaforum.net/threads/excel-cell-color-identification.1039/post-3087

The above link is for Fill Color.
For Font color the only difference is to use the below line of code instead.

Code:
GetWorkbook(handle,Nothing).ActiveSheet.Range(cellref,cellref).Font.Color = RGB(Red_Value, Green_Value, Blue_Value)

In the above case you need to separately pass the columns with a new Action stage.
eg; A:B
Then again a new Action stage for D column.

But if you want to have a single stage and pass all the required columns at once then use the below line of code

GetWorkbook(handle,Nothing).ActiveSheet.Range(cellref).Font.Color = RGB(Red_Value, Green_Value, Blue_Value)

Now you can pass multiple consecutive or non consecutive columns as below.

View attachment 899

and only A, B and D columns will have the new Font color.

View attachment 900

You can also pass row numbers.
For example; when you pass Cell Reference parameter as below,
View attachment 902

then the result will be as below.
View attachment 901

Can you provide a screenshot of the code tab? I feel like the code pasted is only a snippet
 
Top