open excel spreadsheet with password

  • Thread starter Thread starter rocket0612
  • Start date Start date
R

rocket0612

When using a macro to open a spreadsheet, if the spreadsheet is password
protected & I know what the password is, what code would I use to open
the spreadsheet with the password?

thanks
 
Sub OpenProtectedFile()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = Workbooks.Open("C:\Password Protected File.xls", , , ,
"password1", "password2")
Set ws = wb.Sheets("Sheet1")
ws.Activate
ws.Cells(1, 1).Value = "Modified by VBA"
End Sub

"rocket0612" <[email protected]>
schreef in bericht
news:[email protected]...
 

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

Back
Top