Opening password protected Excel files using VB.net

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
* 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.
 
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
 
Back
Top