Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Importing .xlsm, .xlsx with OLEDB

I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
..xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Importing .xlsm, .xlsx with OLEDB

Test my code on this page first on a xlsm file
http://www.rondebruin.nl/ado.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
.xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Importing .xlsm, .xlsx with OLEDB

Funny that you should reply, because your code is actually what I based my
own macro off of. Thank you for that.

Your code does work when i save the test.xls file as test.xlsm. I used your
example 4 because it is most similar to what I am doing. When I use the same
ADO tester on another workbook it fails. I tried to add "Sheet1" to one of
my test workbooks, and also tried changing the sheet that your code pulls
data from, but neither worked. I did find that if a workbook is already open
then my macro works fine, but if it is closed I receive the same error as
before.

Could there actually be a formatting difference between two .xlsm files?

Jeff

"Ron de Bruin" wrote:

Test my code on this page first on a xlsm file
http://www.rondebruin.nl/ado.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
.xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Importing .xlsm, .xlsx with OLEDB

Hi Jeff

If you want send me the file private and I take a look at it this week



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
Funny that you should reply, because your code is actually what I based my
own macro off of. Thank you for that.

Your code does work when i save the test.xls file as test.xlsm. I used your
example 4 because it is most similar to what I am doing. When I use the same
ADO tester on another workbook it fails. I tried to add "Sheet1" to one of
my test workbooks, and also tried changing the sheet that your code pulls
data from, but neither worked. I did find that if a workbook is already open
then my macro works fine, but if it is closed I receive the same error as
before.

Could there actually be a formatting difference between two .xlsm files?

Jeff

"Ron de Bruin" wrote:

Test my code on this page first on a xlsm file
http://www.rondebruin.nl/ado.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
.xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Importing .xlsm, .xlsx with OLEDB

So, I never exactly found out what was wrong with the files, but I decided to
create a new workbook, saved it as a .xlsm file, and copied each sheet and
macro over to it from the files that I needed to import (fortunately there
aren't that many at the moment). Once I did that, I had no problems
importing the files. I guess it doesn't much matter now, but do you know any
reason that could happen?

Jeff

"Ron de Bruin" wrote:

Hi Jeff

If you want send me the file private and I take a look at it this week



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
Funny that you should reply, because your code is actually what I based my
own macro off of. Thank you for that.

Your code does work when i save the test.xls file as test.xlsm. I used your
example 4 because it is most similar to what I am doing. When I use the same
ADO tester on another workbook it fails. I tried to add "Sheet1" to one of
my test workbooks, and also tried changing the sheet that your code pulls
data from, but neither worked. I did find that if a workbook is already open
then my macro works fine, but if it is closed I receive the same error as
before.

Could there actually be a formatting difference between two .xlsm files?

Jeff

"Ron de Bruin" wrote:

Test my code on this page first on a xlsm file
http://www.rondebruin.nl/ado.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
.xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff
.

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Importing .xlsm, .xlsx with OLEDB

Hi Jeff

reason that could happen?


No, sorry

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
So, I never exactly found out what was wrong with the files, but I decided to
create a new workbook, saved it as a .xlsm file, and copied each sheet and
macro over to it from the files that I needed to import (fortunately there
aren't that many at the moment). Once I did that, I had no problems
importing the files. I guess it doesn't much matter now, but do you know any
reason that could happen?

Jeff

"Ron de Bruin" wrote:

Hi Jeff

If you want send me the file private and I take a look at it this week



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
Funny that you should reply, because your code is actually what I based my
own macro off of. Thank you for that.

Your code does work when i save the test.xls file as test.xlsm. I used your
example 4 because it is most similar to what I am doing. When I use the same
ADO tester on another workbook it fails. I tried to add "Sheet1" to one of
my test workbooks, and also tried changing the sheet that your code pulls
data from, but neither worked. I did find that if a workbook is already open
then my macro works fine, but if it is closed I receive the same error as
before.

Could there actually be a formatting difference between two .xlsm files?

Jeff

"Ron de Bruin" wrote:

Test my code on this page first on a xlsm file
http://www.rondebruin.nl/ado.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jeff" wrote in message ...
I have been trying to write a macro to open a closed workbook, copy a
worksheet from it, and then use that data as I need. After surfing the
internet a bit, I was able to find out how to do this using ADO and it was
very useful when operating on .xls workbooks. Now I am trying to use it on
.xlsx and .xlsm workbooks and it fails each time with an error saying
"External table is not in the expected format."

I am using Excel 2007 SP1 and have attempted to install the Access Database
Engine off of the Microsoft website to enable OLEDB to read the new formats.

This is the code that I am using to try to connect:
If Val(Application.Version) < 12 Then
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=No"";"
ElseIf SourceFile Like "*.xlsm" Then
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=No"";"
Else
szConnect = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & SourceFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No"";"

Are there other files that I need to download? Is there something I am
missing in my syntax? Can anyone help me?


Thank you,
Jeff
.

.

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
Importing data from .xlsx files F[_2_] Excel Discussion (Misc queries) 4 January 23rd 12 06:25 PM
How do I set default Excel Saveas file format to xlsx not xlsx Greg Conway Setting up and Configuration of Excel 1 September 17th 08 04:19 PM
Password security problem: view of the hiden worksheet in xlsm and xlsx file !? Ivan Excel Programming 2 December 3rd 07 11:20 AM
OLEDB Help [email protected] Excel Programming 0 December 5th 06 02:19 PM
Bug in OLEDB ? Ric[_4_] Excel Programming 4 June 8th 04 11:45 AM


All times are GMT +1. The time now is 11:36 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"