VBA ADO connection string to excel with workbook password

nd0911

Board Regular
Joined
Jan 1, 2014
Messages
166
Hello,

I'm looking for the right ADO connection string to use inside a Excel workbook (with VBA) to another workbook with a "workbook password".

I'm using this connection string, and it works only when the workbook is without the password

VBA Code:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & MyPath & ";Extended Properties=""Excel 12.0;HDR=YES"";"

Is it possible ?

Thank you.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I think you'll need to first open the workbook using the Open method of the Workbooks object...

VBA Code:
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:="PathAndFilename", Password:="MyPassword")

...and then connect to your workbook using ADO.

Hope this helps!
 
Upvote 0
Thank you Domenic but I dont want to open the file.

Is it possible to do it without open the file anyone ?
 
Upvote 0
I don't know whether it's possible, but you can prevent the workbook from being visible by setting screen updating to false before opening and connecting to your workbook, and then setting it back to true once you've finished...

VBA Code:
Application.ScreenUpdating = False

'your code

Application.ScreenUpdating = True
 
Upvote 0

Forum statistics

Threads
1,214,902
Messages
6,122,161
Members
449,069
Latest member
msilva74

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