Skip to content
Advertisement

How do I open a visible excel full size?

I am running a python script on both my laptop and home computer with:

os.startfile(r'C:\A file.xlsx')

This works great, however I cannot seem to find anywhere on how to make this full size

Any idea on how I can make it full size through python?

I use both Apache OpenOffice and microsoft Excel

image

Advertisement

Answer

You should be able to maximize the window with this:

import win32gui, win32con, os, time

os.startfile('C:\PathToFile.xlsx')
# Wait as long as needed for the file to open, this value can be adjusted as needed
time.sleep(3)
# Now maximize the current foreground window (should be the one we care about at this point)
hwnd = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement