How to click in Excel: "Home" --> "Format" --> "AutoFit Column Width"

Hi all,

I have problems automating click “Home” → “Format” → “AutoFit Column Width” in Excel.

What I tried:

  • Click Button activities → Cannot select “AutoFit Column Width” as it is in a drop down menu
  • Type Into activity with “[d(alt)]hoi”+”[u(alt)]" → works as long as I watch the bot. But as soon as I minimize my server, Type Into activities do not work for me anymore
  • Send hotkey activity with “Alt + hoi”–> Only “h” and “o” are pressed, “i” for some reason does not work

Not sure what I am doing wrong. Please share your ideas!

You can download BalaReva.Excel.Activities. It has an AutoFit Column Activity that can use

1 Like

Hello,

Are you using unattended bot license? If yes, try to check ‘Send Window Message’ checkbox or ‘Simulate Type’ checkbox for ‘TypeInto activity’.

BR,
Chaitanya

Yes I am using an unattended bot. Tried both and tested attendedly first:

‘Send Window Message’ → Works partly: I can see that “h” and “o” are pressed, but I am not sure if “i” is also pressed, as the dropdown from the ribbon disappears in just a few milliseconds and the columns are still not adjusted. (Without “Send Window Message” it works fine attendedly). I think “Send Window Message” could be the way to go, but something is still wrong here

‘Simulate Type’ → Instant Error message “Cannot use UI_CONTROL_API on this UI node. Please use UI_HARDWAREEVENTS method”

Hi @Erik_S

You can use invoke vba activity for this,

VBA_Script.txt (103 Bytes)

Before run change this settings one time in excel.

In order for this activity to work, Trust Access to the VBA project object model must be enabled from Excel ( File > Options > Trust Center > Trust Center Settings > Macro Settings > Select the Trust Access to the VBA project object model check box).

In excel application scope pass your excel name

image

HI @Erik_S

is your issue fixed ?

Hi @Erik_S ,

Take a look at this

Regards
Balamurugan.S

Hi prasath_S

can you please advise on this post

Enable simulate click

Hi @Eric_Wong_Test

Try this Enable modern design
image

Hope this Helps

Regards
Sudharsan