How do I open a visible excel full size?
Question:
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
Answers:
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)
I did
import os
os.system(r'start "" /max EXCEL.EXE ' + path)
The "" /max is what makes it full screen. Path is the full path of the file. Make sure that EXCEL.EXE is discoverable from current directory when executing this.
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
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)
I did
import os
os.system(r'start "" /max EXCEL.EXE ' + path)
The "" /max is what makes it full screen. Path is the full path of the file. Make sure that EXCEL.EXE is discoverable from current directory when executing this.