tags:

views:

44

answers:

1

while my script is updating one excel same time if i am going to do any other work manually with another excel error occurs i am using dispatch

     from win32com.client import Dispatch

     excel    = Dispatch('Excel.Application')
excel.Visible   = True 

file_name="file_name.xls"
workbook = excel.Workbooks.Open(file_name)
workBook  = excel.ActiveWorkbook
sheet=workbook.Sheets(sheetno)

I am geting error like this (, com_error(-2147418111, 'Call was rejected by callee.', None, None)

Is there is any way to overcome it ..can i update another excel without geting error..

A: 

steven may be my variable names are not good but there is no gramatical mistake in code its workes fine my only concern is that com error

my script runs without error if i have not started another excel

my quetion is anyone knows how to overcome it with using dispatch OR is there any other excel module for python where i can deal with this problem?

excel= Dispatch('Excel.Application')

excel.Visible = True

file_name = "E:\Report.xls"

workbook = excel.Workbooks.Open(file_name)

sheet=workbook.Sheets(1)

consider i am writing somethin in excel

sheet.Cells(1,1).Value = 'test1'

sheet.Cells(1,2).Value = 'test2'

sheet.Cells(1,3).Value = 'test3'

sheet.Cells(1,4).Value = 'test4'

sheet.Cells(1,5).Value = 'test5'

sheet.Cells(1,6).Value = 'test6'

sheet.Cells(1,7).Value = 'test7'

sheet.Cells(1,8).Value = 'test8'

sagar