Excel opens with randomly different sizes


#1

When I open excel with an application scope visible true it opens mostly the size it did last time. But occasionally it opens in weird sizes that are not sizes it ever was opened in before and this causes failures in finding the buttons and labels needed in click actions. I tried getting over this with an auto_open sub making the excel an xlsm and trusted. Every time I open that spreadsheet by clicking from the folder list or typing the string into Run: it opens and runs the auto_open. It DOES not do that when opened from UiPath which makes my workaround not helpful. So, why doesn’t the spreadsheet open reliably in whatever size it was last time or some reasonable size? Why doesn’t auto_open work and is there some other event that will work?


#2

Hi,

I don’t follow you fully, but I remember when I initially was working with Excel actions, I was trying to decide if the window was opened a different size where, for example, the Format button was correct or where it could see the complete Ribbon to perform clicks on.

However, I don’t do any of that anymore. I do Alt+key combinations. Like when you press the Alt key you will see characters show up on your ribbon and if you key those, you will see another set of characters and so on.

For example, if I wanted to autosize all the columns, I would do a Select Range followed by a TypeInto Alt+key combo.
TypeInto "[k(alt)]hoi"
with a key delay of about 20 miliseconds.

I don’t know if that will help you any.

Regards.


#3

Hi Bill,

My recommendation would be to use the “send hotkey” function and send the appropriate hotkey which will maximise your excel application (I think ctrl F10?). I was facing the same issue and this was the best workaround that I found.


#4

thanks Clayton and Ollie. I’m doing that in all places that I can find a hot key sequence that works. I was able to find them for most things but there are a few, like maximize the window, that I’ve been unable to make work. And as I was writing this I hit on a site that reminded me of something I had long forgotten. Hit the alt key and you get key tips to tell you what the alt- combination is to select something. I tried it on one of the ones I had not found and got alt-f for file tab, then alt-a for save as (backup sheet before the robot messes with it) and alt-y1 for browse so I can type in the new file name. Now the last test will be to try that in UiPath because I’m using windows 10 in parallels on the mac. :slight_smile:
I still find it “interesting” that UiPath somehow doesn’t respect the sub auto_open which should run every time you open the sheet and that it seems to open in weird ways. One time it opened where the entire sheet windows was 1/4 inch high and 2 inches wide in the upper left corner. Needless to say it could not find the “file” tab.


#5

Hi Bill, what you can try is to set the window size and the location of the window on your screen with the help of some VB code. You can then embed this code into your Excel file and run the code (macro). UiPath supports executing Macro’s from the studio (Excel > “Execute Macro”).

For example:

Sub SetWindowSize()
    Application.WindowState = xlNormal
    Application.Top = 50
    Application.Left = 50
    Application.Width = 720
    Application.Height = 480
End Sub

#6

I did encounter this issue, I did send hot key for Window + up Key.

the resolved the issue, please let me know if that works. Thanks ~Rajesh

Note, I did the windows + Up key short cut 4 times to handle all possible maximum size to happen


#7

I always used to keep the excel windows in maximised window and do the activities using uipath so that there is no issue of window being minimised when you run the automation next time…note( at what state the window was closed last time it opens in the same size when you run the automation again as far as I have worked with uipath).so it’s better to perform automation for excel in full screen mode.
While working with multiple excel files you may provide with hotkeys for maximizing and performing the tasks …
Regards
Abinesh