Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Excel with password in VB 6

Status
Not open for further replies.

DocGrimm

Programmer
Mar 16, 2004
8
US
First hello all, and thanks for answering.

What I'm trying to do is trying to read a single cell (say B2) from an Excel spreadsheet from within VB6.

I've had some success reading unprotected spreadsheets, but I just can't seem to bring it all together. I've searched the forums and don't see anything that can specifically help me.

Can anyone help me out here?

Thanks
 
Hi,
With early binding:

Code:
Dim xlApp As Excel.Application
Dim xlWbk As Excel.Workbook
Set xlApp = New Excel.Application
xlApp.Visible = True 'make it visible to avoid ghost on crash
Set xlWbk = xlApp.Workbooks.Open(FileName:="c:\wbk.xls", Password:="x")
MsgBox xlWbk.Worksheets(1).Range("B2")

combo
 
Thanks,

This was exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top