PC Review


Reply
Thread Tools Rate Thread

ADODB Testing for Password

 
 
Aposto
Guest
Posts: n/a
 
      25th Feb 2010
I have a routine which opens various Excel files and then imports the data in
to Access:

Sub OpenExcelConn(conn As ADODB.Connection, rst As ADODB.Recordset, FileName
As String, SheetName As String)
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
FileName & ";" & "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
rst.CursorLocation = adUseClient
rst.Open "[" & SheetName & "$]", conn, adOpenStatic, adLockOptimistic
End Sub

I have recently added some excel files with passwords to open them and they
obviously fail the above code. How can I modify the code to open Excel files
with or with out passwords?
 
Reply With Quote
 
 
 
 
Stefan Hoffmann
Guest
Posts: n/a
 
      25th Feb 2010
hi,

On 25.02.2010 17:23, Aposto wrote:
> I have recently added some excel files with passwords to open them and they
> obviously fail the above code. How can I modify the code to open Excel files
> with or with out passwords?

Wow, you need to clean up your code...

> Sub OpenExcelConn(conn As ADODB.Connection, rst As ADODB.Recordset, FileName

Why do you name your function "open connection" if it does more than that?

Use error handling and take a look at

http://connectionstrings.com/excel-2007


mfG
--> stefan <--
 
Reply With Quote
 
David C. Holley
Guest
Posts: n/a
 
      28th Feb 2010
If the Excel spreadsheet is passward protected, you'll have to supply the
password, which I'm fairly certain the OpenWorkseet function of the Excel
Application object allows you to do. The catch though is that you have to
store the password so that it can be retrieved.

"Aposto" <(E-Mail Removed)> wrote in message
news2663C6F-77C6-443D-AB67-(E-Mail Removed)...
>I have a routine which opens various Excel files and then imports the data
>in
> to Access:
>
> Sub OpenExcelConn(conn As ADODB.Connection, rst As ADODB.Recordset,
> FileName
> As String, SheetName As String)
> conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
> FileName & ";" & "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"
> rst.CursorLocation = adUseClient
> rst.Open "[" & SheetName & "$]", conn, adOpenStatic,
> adLockOptimistic
> End Sub
>
> I have recently added some excel files with passwords to open them and
> they
> obviously fail the above code. How can I modify the code to open Excel
> files
> with or with out passwords?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: Password not found in ConnectionString for ADODB.Connection in v6.1 Edward Microsoft Access 2 30th Mar 2011 05:19 PM
testing for password in ADODB connection. Aposto Microsoft Access VBA Modules 0 25th Feb 2010 01:42 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft Dot NET 3 25th Sep 2004 10:36 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft VB .NET 3 25th Sep 2004 10:36 PM
URGENT HELP ADODB VbScript vs ADODB.ConnectionClass() C# =?Utf-8?B?U2lsdmlhIEJydW5ldCBKb25lcw==?= Microsoft Dot NET Framework 0 28th Jul 2004 07:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 AM.