Get data from a close Excel Workbook?

P

Pat

Hi,

Does anyone know how can i get data from a close and protect workbook with
vba in word. Any suggestion? with ADO connection of something else?

Best regards,

Pat
 
H

Helmut Weber

Hi Pat,

I'd say, think about another solution.

Maybe you could get an unprotected copy of the Excel-file.

Why is it protected at all?

Probably to prevent people from using the data in the file.

I wonder...


Greetings from Bavaria, Germany

Helmut Weber, MVP, WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
C

Chuck Henrich

Hi Pat

The following will open a workbook, with the password supplied in code, and
display a messagebox with the contents of cell A1. If you leave the password
argument off, Excel will ask for it before opening the workbook. If you
don't know the password then it won't work which is what should happen
(preventing unauthorised access). Is this what you meant?

Dim objExcel As Object
Dim objBook As Object

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False

Set objBook = objExcel.Workbooks.Open("c:\test\book1.xls", Password:="a")

MsgBox objBook.sheets(1).Cells(1, 1)

objBook.Close False 'does not save changes
objExcel.Application.Quit

Set objBook = Nothing
Set objExcel = Nothing
 
P

Pat

Hi Henrich,

Thanks for you answer. Actually i want to to get data without open the Excel
workbook. Ik work correct if the workbook is not protected. What i do is make
an ADO connection to get the data from the Excel workbook. Only when the
workbook is protected with password, ADO connection Doesn't work any more.

By the way thanks anyway. May be there is not any other solution.

Best regards,

Patrick
 

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