使用vb脚本将密码传递给excel文件
我有一个 Excel 文件,它在脚本任务中启用了密码,我正在使用 Vb 读取该文件,
我无法传递密码,以便它允许我从文件中读取。
我该怎么办。密码在哪里可以传递。我还尝试使用 FileInfo 类,但没有选项。
目前的脚本是:
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()
如果文件未启用密码,则它可以工作。任何帮助。请
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用实际的 Excel COM 对象模型。< /a>
Workbook 类有一个属性允许您设置密码。
You could use the actual Excel COM Object Model.
There is a property of the Workbook class that allows you to set the password.