doubt you will be able to do it in macros but you can in VB if you write code to open Excel, open the workbook, remove the password protection then run your query then use VB to set the password protection on again in excel before you save the file. This may point you in the right location...