How to add all borders to excel

Hi all,

I need to add all borders to my excel page. i can do it with start process and excel or with excel pplication scope. But i cannot do it.

I have try to do it as Alt+H+B+A shortcut but i have noticed that uipath cannot run Alt+H shortcut in excel. How can i do that?

2 Likes

@mazlumkacar
You can try using VBA Macro .
I have done using invoke vba activity.
Thanks!

2 Likes

but how may i do that? can you share your code?

1 Like

Use the below code, copy and paste it in a notepad file.
Then use “Invoke VBA Activity”.


Set the Vba text file path.
Change the “Main” name to “Macro1” that we have used in below code.

Sub Macro1()

Worksheets(“Sheet_name”).Range(" ").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.BorderAround ColorIndex:=1

End Sub

thanks!

Thanks a lot. But i am getting this error:(

image

image

@suruchi120294

Have you enabled the macro settings in excel application?
can you share the screenshot of your Invoke activity?


@suruchi120294

Just check on " enable all macros" option or else your macro won’t run.
Thanks!

i did it but getting excatly the same error:(

Should i change something in my macro code?

Is that yellow fill color mean this code is wrong ?

@suruchi120294
@Palaniyappan

1 Like

Hi this would actually work
Use small case of h b and a

The sequence will be like this
—use START PROCESS activity and pass the file path of excel as input which will bring the file to foreground
—then use send hot key activity without any selector chosen and use hot key as alt+h
—then another send hot key with key as b
And final hot key with key as a

Cheers @mazlumkacar

Yes you have to change the Sheetname you are having in the excel file with the specified range that you have to put border to.
Thanks!

i have just try to do it but it is getting error. Mayi would like to you write it for me? :sweat_smile:

sheet name is “Sheet1”
range is all columns that has data.

@suruchi120294

Fine
The steps involved will be like this
—use START PROCESS activity and mention the file path of excel as input
—now this will bring the excel to foreground
—then use a SEND HOT KEY activity and mention the input as ctrl+g
—now use a TYPE INTO activity and mention the input as “A1”
—then use a SEND HOT KEY activity with key as ctrl+A
—now send hot key with key as alt+h
—another send hot key with key as “b”
—final send hot key with key as “a”

It worked when I tried to simulate
Cheers @mazlumkacar

4 Likes

Perfect solution. Thanks buddy. @Palaniyappan

1 Like

Cheers @mazlumkacar

Hi all.
I knew it fixed by @palaniyappan . Here is an activity called “Set Border” to set border to the range or a cell.

Regards
Balamurugan.S

2 Likes

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