473,591 Members | 2,899 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Workbook s.Add()
Sheets = workbook.sheets
defaultWorkshee ts = workbook.Worksh eets(1)
excel.applicati on.displayalert s = 0

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

datasheet = port_sheets(1)

datasheet.Activ ate()
datasheet.Cells .Select()

excel.Selection .Copy()

Sheets.Add().Na me = port.name
newsheet=workbo ok.Worksheets(p ort.name)
newsheet.Activa te()
newsheet.Paste( )

port_book.Close (SaveChanges=0)

Nov 8 '08 #1
1 4488
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.Workbook s.Add()
Sheets = workbook.sheets
defaultWorkshee ts = workbook.Worksh eets(1)
excel.applicati on.displayalert s = 0

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

datasheet = port_sheets(1)

datasheet.Activ ate()
datasheet.Cells .Select()

excel.Selection .Copy()

Sheets.Add().Na me = port.name
newsheet=workbo ok.Worksheets(p ort.name)
newsheet.Activa te()
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
35519
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
4
21023
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 transparent excel window... my os is win 2000 pro... Which is the right way to close an excel applicatio from python? Thanks
3
6996
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 and Word examples run fine. win32com.client.Dispatch("Excel.Application") etc., but how does one know the ("<foo>.<bar>") to type in? Excel looks only vaguely like "Excel.Application" in the com browser.
3
3995
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 2000, but in Office 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" Please help me :-( the code of the module that crash is (only in Excel 2003, in 2000 not): import os
4
16996
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 = 1 But when I try my application which is QeepIt.exe which is in the c:\ drive it is not running Any body tell me how to give path to open an exectable application in
2
9202
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
4882
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 through Task Manager. Reading up on other threads indicate that maybe I still have some Excel objects referenced within my code. Is this why the process doesn't terminate? The related (I hope) parts of my code is here. x1App =...
2
5727
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 "testexcel.py", line 3, in ? excel = Dispatch("Excel.Application") File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 95, in
2
3952
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 having is closing down the excel application. Here some "bits" of the code I am using: xlApp = Dispatch("Excel.Application") xlApp.Workbooks.Open(Filename = path+fname)
0
7934
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7870
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8236
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8362
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7992
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6639
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5732
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.