This seems to work, though I've only tested it briefly.
Note that in this form it can easily be tricked into leaving the
workbook without its password. Defensive coding and error trapping could
reduce the likelihood of this happening but - as far as I know - there's
no way of eliminating it.
Public Sub ExportToPasswordedWorkbook(strFile As String, _
strPassword As String, strQryName As String)
Dim oExcel As Excel.Application
Dim oWb As Excel.Workbook
Set oExcel = CreateObject("Excel.Application")
'Open protected workbook and remove password
Set oWb = oExcel.Workbooks.Open(FileName:=strFile, _
Password:=strPassword)
oWb.Password = ""
oWb.Close SaveChanges:=True
'Export
DoCmd.TransferSpreadsheet acExport, _
acSpreadsheetTypeExcel9, strQryName, strFile, -1
'Restore password
Set oWb = oExcel.Workbooks.Open(FileName:=strFile)
oWb.Password = strPassword
oWb.Close SaveChanges:=True
oExcel.Quit
Set oExcel = Nothing
End Sub