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
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