views:

130

answers:

2

Hello,

I'm trying to open a write-protected ms excel 2007 file using win32com in python -- I know the password. I can open it with user input of the password into the excel dialog box. I want to be able to open the file without any user interaction. I've tried the following, but it still pops up the dialog box.

app.Workbooks.Open("filename.xls", WriteResPassword="secret")

Any ideas what I'm doing wrong please?

Thanks,

Dave.

A: 

I can get the above code to work if I don't try to use named function parameters. I.e. the following works:

app.Workbooks.Open("filename.xls", 2, True, None, None, "secret")
Dave Potts
A: 
import sys
import win32com.client

xlApp = win32com.client.Dispatch("Excel.Application")
print "Excel library version:",xlApp.Version
fileName = 'C:/Users/Leyond/workspace/ExcelTest/src/Book1.xls'
xlwb = xlApp.Workbooks.Open(fileName,2, True, None, None, "secret")
xlwb.Close()
xlApp.Quit()

do you mean like this, it doesn't work at all. it still needs user interaction to input the password. how?

Leyond
I fixed it using:xlwb = xlApp.Workbooks.Open(fileName, 2, True,None, 'secret','')
Leyond