BookmarkSubscribeRSS Feed
Oleg_L
Obsidian | Level 7

Hello SAS-Users.

I use the code below to access lots of Excel files that we receive from our subsidiaries.

libname myxls oledb access=readonly provider="Microsoft.ACE.OLEDB.12.0"

properties=("data source"="&fullname" "Mode"="Read")

provider_string="Excel 12.0;ReadOnly=True;HDR=no;IMEX=1;"

;

Excel files are in .xlsb format.

This code works fine.

But for some files i get the error:

ERROR: Error trying to establish connection: Unable to Initialize: External table is not in the expected format.

ERROR: Error in the LIBNAME statement.

These problem Excel files are opening in Excel without any errors.

I tried to open file in Excel and save it as another copy. But it does not help.

The only way i found :

1.  Open file in Excel

2. Copy and paste only values (paste special) to another file.

3. Save this new file and then import.

I hope someone knows how to solve this problem. May be i missed some option in the libname statement.

Files are hundreds and it is very difficult manually copy/paste data.

Thanks in advance.

Oleg.

2 REPLIES 2
Oleg_L
Obsidian | Level 7

I find out that error files have protected structure enabled with a password.

I googled some information about this protection. Programmers (non-SAS) say that it is not possible to make an OLEDB access to protected Excel files.

I can not use DDE unfortunatly. I am running EG.

Oleg.

bentleyj1
Quartz | Level 8

I'm not familiar with using the OLDB engine but I use the Excel engine quite a bit.  I don't work with password-protected spreadsheets and I don't work with .xlsb files but I _think_ it has an option that allows you to pass a password to Excel.

Check the documentation on the Excel libname engine.  You'll likely have to rework your code to use the Excel engine but it might be a solution.

Thanks for the tip about password-protected files throwing this error.

Good Luck.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1544 views
  • 0 likes
  • 2 in conversation