Protect a Worksheet
For your option 2 that was part of my question where do I put the protect so
that it is after the query has ran?
For your option 1 I tried running the query but I don't know the correct
syntax. It doesn't like it and says function or procedure is not defined. How
do I execute the Query?
I tried:
Private Sub Workbook_Open()
Call Query_from_Donald_5
Const PWORD As String = "drowssap"
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Protect PWORD
Next wsSheet
End Sub
And I also tried:
Private Sub Workbook_Open()
Query_from_Donald_5
Const PWORD As String = "drowssap"
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
wsSheet.Protect PWORD
Next wsSheet
End Sub
"Otter" wrote:
I have a worksheet that has a parameter query that was set up through the
Import External Data option. It is set to refresh on open and it errors out
if I protect the worksheet and save it. I have tried protecting the worksheet
with code but can't seem to find the correct place to put the code. I tried
it in "This Workbook" but it protects it before the query runs and does the
update. I have put the protect in the begining of the worksheet that I want
to protect but it does not protect it. Any ideas?
|