Reputation: 193
i have a excel file it is password enabled in a script task i am reading the file using Vb
I am not able to pass the password so that it allows me to read from the file.
How can i do it.Where can i pass the password. I also tried using FileInfo class there is no option for that.
present script is:
Dim fs As FileStream
Dim sr As StreamReader
Dim line As String
fs = File.OpenRead(Dts.Variables("File_Name").Value)
sr = File.OpenText(Dts.Variables("File_Name").Value)
'Read first line of the file
line = sr.ReadLine
Dim str As String
str = line
sr.Close()
fs.Close()
It works if the file is not password enabled.Any help. Please
Upvotes: 0
Views: 558
Reputation: 65187
You could use the actual Excel COM Object Model.
There is a property of the Workbook class that allows you to set the password.
Upvotes: 2