473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to shut-down Excel from Python

Elias Alhanatis
Hello to everybody!

I have created an app which calculates some statistical data.
I use the following function to get Excel to print a page with the data.

Code: ( text )

def Create_Analysis_Page(Name,Job,Phone,Month,Analysin g_Dict,preview=False):
xlApp = Dispatch ("Excel.Application")
xlWb = xlApp.Workbooks.Open ("C:\\Python25\\Misthos.xlsx")
xlSht = xlWb.Worksheets (1)

xlSht.Cells(1,2).Value=str(Name)
xlSht.Cells(2,2).Value=str(Job)
xlSht.Cells(3,2).Value=int(Phone)
xlSht.Cells(5,2).Value=str(Month)

try:
for i in range (9,40):
xlSht.Cells(i,2).Value=Analysing_Dict[i-8][0]
xlSht.Cells(i,3).Value=Analysing_Dict[i-8][1]
xlSht.Cells(i,4).Value=Analysing_Dict[i-8][2]
except:
pass

xlSht.Cells(41,4).Value=Analysing_Dict["Totals"][0]
xlSht.Cells(42,4).Value=Analysing_Dict["Totals"][1]
xlSht.Cells(43,4).Value=Analysing_Dict["Totals"][2]

#Preview or not....
if preview:
xlApp.Visible=1

#Print The Sheet...
xlSht.PrintOut()

xlApp.Workbooks.Close()

xlApp.Quit()



My problem is in the last few lines , because when Excel shuts down , it pops up a "Save Changes" dialog , which is never the case in my app. How can i bypass this?


Thank you in advance!!!

Elias
Apr 26 '08 #1
4 1193
xlWb.Close SaveChanges:=False

Hello to everybody!
I have created an app which calculates some statistical data.
I use the following function to get Excel to print a page with the data.
Code: ( text )

def Create_Analysis_Page(Name,Job,Phone,Month,Analysin g_Dict,preview=False):
xlApp = Dispatch ("Excel.Application")
xlWb = xlApp.Workbooks.Open ("C:\\Python25\\Misthos.xlsx")
xlSht = xlWb.Worksheets (1)

xlSht.Cells(1,2).Value=str(Name)
xlSht.Cells(2,2).Value=str(Job)
xlSht.Cells(3,2).Value=int(Phone)
xlSht.Cells(5,2).Value=str(Month)

try:
for i in range (9,40):
xlSht.Cells(i,2).Value=Analysing_Dict[i-8][0]
xlSht.Cells(i,3).Value=Analysing_Dict[i-8][1]
xlSht.Cells(i,4).Value=Analysing_Dict[i-8][2]
except:
pass

xlSht.Cells(41,4).Value=Analysing_Dict["Totals"][0]
xlSht.Cells(42,4).Value=Analysing_Dict["Totals"][1]
xlSht.Cells(43,4).Value=Analysing_Dict["Totals"][2]

#Preview or not....
if preview:
xlApp.Visible=1

#Print The Sheet...
xlSht.PrintOut()

xlApp.Workbooks.Close()

xlApp.Quit()



My problem is in the last few lines , because when Excel shuts down , it pops up a "Save Changes" dialog , which is never the case in my app. How can i bypass this?
Thank you in advance!!!

Elias
Apr 27 '08 #2
Thanks a lot friend!!!!
Short , and to the point!!!!

Elias
Apr 28 '08 #3
Hi there

I want the opposite
and i am having a blonde day

i can't save it
Excel.Saved = 1 obviously only works if you have opened the document
however for the life of me today i can't figure out how to save it once i have created it as it pops up a save dialogue box

cheers
D2
May 9 '08 #4
Hi there

I want the opposite
and i am having a blonde day

i can't save it
Excel.Saved = 1 obviously only works if you have opened the document
however for the life of me today i can't figure out how to save it once i have created it as it pops up a save dialogue box

cheers
D2
total blonde moment
com_objectName.SaveAs(Filename)

oh dear...

D2
May 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
3
by: Todd Nathan | last post by:
Have ported Until 2.5.2 which is a highly portable embedded FORTH-like language system to BeOS. Turned on -Wall cause I'm anal about cleaning up ports if I'm doing them, and have all but ONE...
8
by: ApexData | last post by:
Hello I have just completed the development of a turn-key Access2k application. I am using MS Access 2000k application, not the RunTime. I have compiled it, split it (FE & BE), set all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.