TransferSpreadsheet with Password

Tricky1

New Member
Joined
May 12, 2015
Messages
4
Hello

I've been using the below the code to import numerous excel spreadsheets from a specific folder into an access table, however the spreadsheets are all now protected with the same password. Does any one know how I can define the password in this code, preferably without opening and closing each file.

Many thanks

Function TemplateImport()
Dim strPathFile As String, strFile As String, strPath As String
Dim blnHasFieldNames As Boolean
Dim intWorksheets As Integer
Dim strWorksheets(1 To 1) As String
Dim strTables(1 To 1) As String
strTables(1) = "tbl_template_temp"
blnHasFieldNames = True
strPath = "T:\Workspace”
For intWorksheets = 1 To 1
strFile = Dir(strPath & "*.xlsx")
Do While Len(strFile) > 0
strPathFile = strPath & strFile

DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel12, strTables(intWorksheets), _
strPathFile, blnHasFieldNames, "A1:AS1000"
'
strFile = Dir()
Loop

Next intWorksheets

End Function
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

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