ADO Connection to Current Workbook - Error when Read Only

mgmirvine

New Member
Joined
Dec 2, 2011
Messages
4
All,

Firstly, thank you for any help you can provide.

I have a workbook test.xlsm, which has two sheets, Data and Report. Then, I have some VBA that creates an ADO Connection to Data in order to run SQL to pull some data from Data into Report, see below. When I open the workbook it runs just fine. However, if I set the file property to read-only, I get an error: "Run-time error '-2147467259 (80004005)': External table is not in the expected format." ... The reason it needs to work in Read-Only format, is this will be available to the end user on SharePoint, where they will open the file as read only just to view the report.


Code:
Dim MyConnection As Connection
Dim Myrecordset As Recordset
Dim MyWorkbook As String
 
Set MyConnection = New Connection
Set Myrecordset = New Recordset
  
'Identify the workbook you are referencing
    MyWorkbook = Application.ThisWorkbook.FullName
 
'Open connection to the workbook
MyConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                  "Data Source=" & MyWorkbook & ";" & _
                  "Extended Properties=Excel 12.0;IMEX=1;" & _
                  "Persist Security Info=False"


Again, thank you!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,215,764
Messages
6,126,751
Members
449,335
Latest member
Tanne

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top