Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default ADO connection to a protected workbook?

I am making an ADO connection to macro enabled workbooks
(i.e, workbooks of type *.xlsm). Here is my connection string example:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\data.xlsm;
Extended Properties=""Excel 12.0 Macro;HDR=NO;IMEX=1"""

So far, I have been able to make connections to very simple and basic
Excel 2007 macro files. However, when I try connecting to a workbook
that is password protected (with all sheets being password protected as
well),
then I CANNOT make a connection. I get an error message that reads
something like "Table is not in the expected format".

So, my question is, is ADO useless if the workbook is password protected?
This workbook also contains hidden sheets, so I wonder if that's the
problem?
What sort of things will prevent an ADO connection? I know I do have the
correct connection string, so something else must be wrong.

Thank you!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default ADO connection to a protected workbook?

Robert Crandal submitted this idea :
I am making an ADO connection to macro enabled workbooks
(i.e, workbooks of type *.xlsm). Here is my connection string example:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\data.xlsm;
Extended Properties=""Excel 12.0 Macro;HDR=NO;IMEX=1"""

So far, I have been able to make connections to very simple and basic
Excel 2007 macro files. However, when I try connecting to a workbook
that is password protected (with all sheets being password protected as
well),
then I CANNOT make a connection. I get an error message that reads
something like "Table is not in the expected format".

So, my question is, is ADO useless if the workbook is password protected?
This workbook also contains hidden sheets, so I wonder if that's the problem?
What sort of things will prevent an ADO connection? I know I do have the
correct connection string, so something else must be wrong.

Thank you!


I'll have to do some looking into the password protected wkb issue.
I'll post my findings...

Meanwhile, (just a word of caution) though Jet/Ace are somewhat
forgiving and so let you get away without using the closing semi-colon
in front of your closing double quote, some other providers may not
allow that in your connection string. <IMOIt's just good practice to
always include it as a general rule.

"...;IMEX=1"";"

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default ADO connection to a protected workbook?

It turns out, the mistake was actually my own. My query string looked
like this:

szSQL = "SELECT * FROM [Sheet1$A1:A1]"

The problem was, my workbook (which is protected), did not have
any sheets named "Sheet1", which probably explains why I got the error that
said "External table was not in the expected format.". Does that sound
right?

It therefore looks like I CAN make a connection to a password protected
sheet, I just need to reference actual sheet names, haha!

My bad!



"GS" wrote in message
...
Robert Crandal submitted this idea :

I'll have to do some looking into the password protected wkb issue. I'll
post my findings...


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default ADO connection to a protected workbook?

Robert Crandal laid this down on his screen :
It turns out, the mistake was actually my own. My query string looked
like this:

szSQL = "SELECT * FROM [Sheet1$A1:A1]"

The problem was, my workbook (which is protected), did not have
any sheets named "Sheet1", which probably explains why I got the error that
said "External table was not in the expected format.". Does that sound
right?


ADO error messages aren't the most intuitive for all scenarios, which
means they can be misleading. But yes, you must specify the sheetname
that contains the data you want. This precludes then that your
workbooks containing the data should be similar in structure for
sheetnames.<g

It therefore looks like I CAN make a connection to a password protected
sheet, I just need to reference actual sheet names, haha!

My bad!



"GS" wrote in message
...
Robert Crandal submitted this idea :

I'll have to do some looking into the password protected wkb issue. I'll
post my findings...


Here's what I got back from Rob Bovey regarding the open password
protection:

<From Rob Bovey
There isn't any ADO solution for password protected workbooks unless
you
consider letting Excel open them first, which kind of defeats the
purpose of ADO even if it works technically. The contents of a password
protected workbook are encrypted by Excel and ADO has no way to decrypt
it.
</

And yes, ADO works if sheet protection is in place as that doesn't
matter because that's only for the UI.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use workbook name in Connection James_G Excel Programming 3 February 5th 08 03:14 AM
using ado db connection in different workbook RB Smissaert Excel Programming 14 November 5th 06 11:36 AM
Group, Outline, Protected Worksheets and Protected Workbook BEEJAY Excel Programming 0 February 13th 06 08:40 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"