UserInterFaceOnly won't allow query to refresh

I'm trying to set up a workbook to allow my macros to run while protection is on (without a password). I've got the following code in the private module of ThisWorkbook.

Private Sub Workbook_Open()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Protect UserInterFaceOnly:=True
Next wSheet
End Sub

When I run my macros, The ones that have query.refresh  get the runtime error saying the cell I am trying to change is protected.  Does UserInterFaceOnly not apply to query refresh?
Is there some other setting or code I need to make this work? Does it matter if I have protection on or off in each worksheet? I'm using Excel 2003. My query pulls data from a csv file.
My macros run fine if I unprotect every sheet manually and don't use the UserInterFaceOnly, but I need to have the sheets protected.  I would rather not use protect/unprotect in the macro because if the macro gets terminated then protection is not set.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I can't get it to work either.  Apparantly, there is too much going on with a refresh, column widths, formatting, sorts and filters, new rows inserted, and I tried disabling all of that and the query still won't run.

You need to use an On Error statement to protect the sheet if an error occurs in the macro.
Sub Macro3()
    On Error GoTo rollback
    ActiveSheet.Cells(1, 1).Value = "Older"  ' overwritten if refresh succeeds, cheap debug flag
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, userinterfaceonly:=True
    Exit Sub
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, userinterfaceonly:=True
    MsgBox "protected again"
End Sub

Open in new window

jfwsmithAuthor Commented:
So apparently no one else has run into this problem?  Seems odd that Query.Refresh would not to allowed under UserInterFaceOnly.  Can anyone else verify this?
Consider it verified.  Poor choice of words I guess, but I only meant to imply I hadn't used a rigourous QA testing process.  A google search turned up only articles that agreed that unprotect / query.refresh / protect is the only option.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

I suppose the B grade was intended as a sign of protest to Microsoft, for omitting this obviously useful feature :)
I'll gladly be the messenger, even if it ends up getting me shot! lol
jfwsmithAuthor Commented:
Sorry, I'm not familiar with what the grading is all about.  No reflection on you personally, the answer just didn't tell me much that I didn't already know... (I already googled it myself, my reason for posting here was to seek further clarification).  Thank you for your response and efforts.
No offense was taken, so think nothing of it, really.  Maybe it was a bit snarky, but I couldn't resist the joke.  Many a time, posters grade on what they hoped to hear, rather than the response's accuracy.  Funny but only human I guess, its very widespread.  I apologize if I seemed ungrateful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Project Management

From novice to tech pro — start learning today.