Excel Formatting

soraj

New Member
hi,
I want to write a code such that it formats the excel file like font-color of some particular cells, cell colors of a particular column etc using c# code stage in blue prism.
Please help
 

VJR

Well-Known Member
hi,
I want to write a code such that it formats the excel file like font-color of some particular cells, cell colors of a particular column etc using c# code stage in blue prism.
Please help
Below links would help to achieve the same. They are in Visual Basic. If you wish to write in C# then you would need to convert the same.

For highlighting a cell or range of cells you can use Post #2 in the below link
http://rpaforum.net/threads/excel-cell-color-identification.1039/post-3087

For making the font red you could look at Post #2 here.
http://rpaforum.net/threads/coloring-text-in-excel-file.1324/post-4054
 

soraj

New Member
and one more thing, if i am formatting any excel sheet from blue prism, can i use action stages for creating instance and opening workbook and then code stage for formatting?
or i will have to code the complete above mentioned process in the code stage?
please clear this.
 

sivagelli

Well-Known Member
Thank you for the reply. but how to convert it in c#? now that's an issue for me.
The easiest would be to use Excel VBA instead of C# for any excel related coding.
You have to extend the existing Excel VBO and add a new page with Code stage and necessary code you need to format the worksheet. Once you publish the newly created page. You can use this as any other action in Excel VBO.

Hope this helps!
 

soraj

New Member
The easiest would be to use Excel VBA instead of C# for any excel related coding.
You have to extend the existing Excel VBO and add a new page with Code stage and necessary code you need to format the worksheet. Once you publish the newly created page. You can use this as any other action in Excel VBO.

Hope this helps!
For coding in VB in blue prism, what all references and imports should i add in the initialise page of the object??
 

sivagelli

Well-Known Member
Check VJR post whcih says to-

You can make a copy of the existing 'Format Cell' action of the MS Excel VBO.
Remove the existing code and add the below line to the Code stage.

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

sivagelli

Well-Known Member
You have to make a duplicate copy of the 'Format Cell' in to Excel VBO object and change the Code with the above line. I am supposing you are creating a new object outside of MS Excel VBO. So, the function is not being recognized.

If you open the MS Excel VBO and go to Initialize page and click on the Object Propoerties, on the Global Code tab there are bunch of functions defined, one of the functions is 'GetWorkbook'. On the new object you are creating there is no function defined in Global Code section, so BP is showing you the error.

Hope this helps!
 
Top