I am running a python script on both my laptop and home computer with:
JavaScript
x
2
1
os.startfile(r'C:\A file.xlsx')
2
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
Advertisement
Answer
You should be able to maximize the window with this:
JavaScript
1
9
1
import win32gui, win32con, os, time
2
3
os.startfile('C:\PathToFile.xlsx')
4
# Wait as long as needed for the file to open, this value can be adjusted as needed
5
time.sleep(3)
6
# Now maximize the current foreground window (should be the one we care about at this point)
7
hwnd = win32gui.GetForegroundWindow()
8
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
9