472,354 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Dispatch('Excel.Application') on Vista from Task Scheduler

I have a python script that runs fine from the command line or from
within IDLE, but doesn't work through the Vista Task Scheduler.

The script downloads some csv files and then uses pywin32 to combine
the csv files into a single document. When I run it through the task
scheduler, it downloads the csv files, but then doesn't seem to launch
excel. I can't figure out what is wrong or how to add enough logging
to tell.

I'm using Python 2.6 and pywin32-212.win32-py2.6 on Vista.

Code snippet below.

Any ideas? Does it have something to do with permissioning on Vista?
I'm running the task as my regular user (that has administrative
privileges).

Thanks,
Theo
---------------
from win32com.client import Dispatch
.....
excel = Dispatch('Excel.Application')
excel.visible =0
print 'launched excel'
workbook =excel.Workbooks.Add()
Sheets = workbook.sheets
defaultWorksheets = workbook.Worksheets(1)
excel.application.displayalerts = 0

for port in portList:
print 'about to open' + basePath + port.filename
port_book = excel.Workbooks.Open( basePath +
port.filename)
port_sheets = port_book.Sheets

datasheet = port_sheets(1)

datasheet.Activate()
datasheet.Cells.Select()

excel.Selection.Copy()

Sheets.Add().Name = port.name
newsheet=workbook.Worksheets(port.name)
newsheet.Activate()
newsheet.Paste()

port_book.Close(SaveChanges=0)

Nov 8 '08 #1
1 4414
Cupric wrote:
I have a python script that runs fine from the command line or from
within IDLE, but doesn't work through the Vista Task Scheduler.

The script downloads some csv files and then uses pywin32 to combine
the csv files into a single document. When I run it through the task
scheduler, it downloads the csv files, but then doesn't seem to launch
excel. I can't figure out what is wrong or how to add enough logging
to tell.

I'm using Python 2.6 and pywin32-212.win32-py2.6 on Vista.

Code snippet below.

Any ideas? Does it have something to do with permissioning on Vista?
I'm running the task as my regular user (that has administrative
privileges).

Thanks,
Theo
---------------
from win32com.client import Dispatch
....
excel = Dispatch('Excel.Application')
excel.visible =0
print 'launched excel'
workbook =excel.Workbooks.Add()
Sheets = workbook.sheets
defaultWorksheets = workbook.Worksheets(1)
excel.application.displayalerts = 0

for port in portList:
print 'about to open' + basePath + port.filename
port_book = excel.Workbooks.Open( basePath +
port.filename)
port_sheets = port_book.Sheets

datasheet = port_sheets(1)

datasheet.Activate()
datasheet.Cells.Select()

excel.Selection.Copy()

Sheets.Add().Name = port.name
newsheet=workbook.Worksheets(port.name)
newsheet.Activate()
newsheet.Paste()

port_book.Close(SaveChanges=0)
Normally this has more to do with the context that the app runs in under Task
Scheduler not having the same environment as the logged in user. Try telling
the Task Scheduler to run the application using the same credentials as the
foreground user to see if that makes a difference.

-Larry
Nov 9 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
4
by: federico | last post by:
When I close an excel application opened from a python program with .Close() methood , in tasks manager is still present 'excel.exe' process and if I open manually an excel applicaion I have a...
3
by: RJ | last post by:
Hi, I've been going over the Quick Start to Client side COM and Python and many other sources, but cannot find an example that will get my com/ActiveX .ocx USB device driver imported. The Excel...
3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
4
by: vithi | last post by:
Hi' I am trying to launch an application. When I try like that When I try like that Excel is opening import win32com.client object = win32com.client.Dispatch("Excel.Application") object.Visible...
2
by: Ray | last post by:
Hi, I need to use cell's background color. when I record a macro from excel, it shows: Rows("7:7").Select With Selection.Interior .ColorIndex = 8 .Pattern = xlSolid
3
by: Chris | last post by:
I have a python script that is driving Excel and using the win32com module. However, upon program completion there's still an Excel.exe process running in the background that I must terminate...
2
by: lialie | last post by:
Hi, Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in my env setting? My excel version is 2003. any suggestion? Thanks. Traceback (most recent call last): File...
2
by: Silgd1 | last post by:
Hi All.... I'm using python 2.4, Win XP Pro v.2002 sp3, and I use pyscripter 1.9.9.2 as my editor. I have written code to open an existing excel file and grab some data. The problem I am...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

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.