Opening password protected Excel files using VB.net

G

Guest

I am writing a small program that needs to be able to open Excel
workbooks which are password protected. Does anyone know how to do this,
without any interaction from the user? I am sure it is something simple that
I am missing.



Here is the relevant section of my code:



ExcelApp = CType(CreateObject("Excel.Application"),
Excel.Application)

ExcelBook = ExcelApp.Workbooks.Open(File)

ExcelBook.Password = "aaaaaa"









ExcelSheet = ExcelBook.Worksheets("Sheet Sorted by Section Number")

ExcelApp.Visible = True
 
H

Herfried K. Wagner [MVP]

* said:
I am writing a small program that needs to be able to open Excel
workbooks which are password protected. Does anyone know how to do this,
without any interaction from the user? I am sure it is something simple that
I am missing.

You may want to ask this question here:
microsoft.public.excel.programming.
 
B

Blumidoo

I am writing a small program that needs to be able to open
Excel
workbooks which are password protected. Does anyone know how to do this,
without any interaction from the user? I am sure it is something simple that
I am missing.

..Open method has many parameters, one of them is Password.

Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword,
IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter,
AddToMru, Local, CorruptLoad, OpenConflictDocument)

Read
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl10/html/xlmthOpen.asp
in MSDN, it should help you.

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top