Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Dispatch('Excel.Application') on Vista from Task Scheduler

Reply
Thread Tools

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

 
 
Cupric
Guest
Posts: n/a
 
      11-08-2008
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)

 
Reply With Quote
 
 
 
 
Larry Bates
Guest
Posts: n/a
 
      11-09-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dotnet scheduler like the Windows "Schedued Tasks" scheduler? Codemonkey ASP .Net 8 06-10-2011 10:53 AM
Windows Task Scheduler password problem David Computer Support 9 11-10-2009 12:18 PM
Task Scheduler Won't Work =.RLM.= Computer Support 1 11-03-2003 07:28 PM
Windows Task Scheduler David Computer Support 0 10-07-2003 02:06 AM
windows xp home edition task scheduler problems rtdos \(status@rtdos.info\) Computer Support 0 07-15-2003 04:07 AM



Advertisments