Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default protect - macro?

Hey guys,
I have this macro and I want my worksheet to be protected but it says I am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default protect - macro?

I forgot one thing, the code...
so here it is:

Private Sub Worksheet_Activate()
Call Main
End Sub

Sub Main()
Dim hideRows As Range
Application.ScreenUpdating = False
With Range("G3:G2401")
.EntireRow.Hidden = False
.AutoFilter Field:=1, Criteria1:="="
On Error Resume Next
Set hideRows = .Offset(1, 0).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
Selection.AutoFilter
If Not hideRows Is Nothing Then hideRows.EntireRow.Hidden = True
Range("G202,G402,G602,G802,G1002,G1202,G1402," & _
"G1602,G1802,G2002,G2202,G2402").EntireRow.Hid den = False
Application.ScreenUpdating = True
End Sub


Thanks
--
Stu


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default protect - macro?

"It" says ???

You have two options. One is protecting by code, userinterface only:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

Now macros can do more things than the user is allowed.

Or you can simply have your macro unprotect-work-protect like this

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message ...
Hey guys,
I have this macro and I want my worksheet to be protected but it says I am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default protect - macro?

What if the user looks in the code? the password is viewable.


--
Stu


"Harald Staff" wrote in message
...
"It" says ???

You have two options. One is protecting by code, userinterface only:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

Now macros can do more things than the user is allowed.

Or you can simply have your macro unprotect-work-protect like this

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message

...
Hey guys,
I have this macro and I want my worksheet to be protected but it says I

am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default protect - macro?

You can prevent that in the VB editor menu Tools VBA proj Properties Protection. But
I'd prefer hiding or masking the password instead; unlocked code may provide you with good
debugging information until the code is perfect.

Anyway, you're too paranoid. Excel is not safe and sheet passwords can be cracked easily.
Security is basically there to prevent fools from doing severe damage to formulas, not to
protect our digital rights.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message ...
What if the user looks in the code? the password is viewable.


--
Stu


"Harald Staff" wrote in message
...
"It" says ???

You have two options. One is protecting by code, userinterface only:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

Now macros can do more things than the user is allowed.

Or you can simply have your macro unprotect-work-protect like this

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message

...
Hey guys,
I have this macro and I want my worksheet to be protected but it says I

am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default protect - macro?

That is true I am too paranoid and for no reason, because like you say it is
to prevent fools from messing with things they shouldn't but I know a lot of
fools who will probably venture into the code and mess that up too.

And I cant seem to get the:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

or

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

to work.

Thanks
--
Stu
"Harald Staff" wrote in message
...
You can prevent that in the VB editor menu Tools VBA proj Properties

Protection. But
I'd prefer hiding or masking the password instead; unlocked code may

provide you with good
debugging information until the code is perfect.

Anyway, you're too paranoid. Excel is not safe and sheet passwords can be

cracked easily.
Security is basically there to prevent fools from doing severe damage to

formulas, not to
protect our digital rights.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message

...
What if the user looks in the code? the password is viewable.


--
Stu


"Harald Staff" wrote in message
...
"It" says ???

You have two options. One is protecting by code, userinterface only:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

Now macros can do more things than the user is allowed.

Or you can simply have your macro unprotect-work-protect like this

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message

...
Hey guys,
I have this macro and I want my worksheet to be protected but it

says I
am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default protect - macro?

Why are you talking about users. You said *You* would be using xl2002, so
limitations of xl97 were of no consequence. Now you have users - will they
all also be using xl2002? If not, you have more surprises headed your way.

Using userinterfaceonly will not work with your autofilter code.
Userinterfaceonly only works with an already existing filter. There is no
reason the unprotect shouldn't work if you spell it correctly and the
password is the correct password.

The other method I showed will work with userinterfaceonly, of course.

--
Regards,
Tom Ogilvy



Stu wrote in message
...
That is true I am too paranoid and for no reason, because like you say it

is
to prevent fools from messing with things they shouldn't but I know a lot

of
fools who will probably venture into the code and mess that up too.

And I cant seem to get the:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

or

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

to work.

Thanks
--
Stu
"Harald Staff" wrote in message
...
You can prevent that in the VB editor menu Tools VBA proj Properties

Protection. But
I'd prefer hiding or masking the password instead; unlocked code may

provide you with good
debugging information until the code is perfect.

Anyway, you're too paranoid. Excel is not safe and sheet passwords can

be
cracked easily.
Security is basically there to prevent fools from doing severe damage to

formulas, not to
protect our digital rights.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message

...
What if the user looks in the code? the password is viewable.


--
Stu


"Harald Staff" wrote in message
...
"It" says ???

You have two options. One is protecting by code, userinterface only:

Sheets(1).Protect Password:="Yo", _
UserInterfaceOnly:=True

Now macros can do more things than the user is allowed.

Or you can simply have your macro unprotect-work-protect like this

Sheets(1).Unrotect Password:="Yo"
'autofilter, hide, stuff
Sheets(1).Protect Password:="Yo"

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message
...
Hey guys,
I have this macro and I want my worksheet to be protected but it

says I
am
not able to protect the sheet because of the macro.
Is there any way around it?

Thanks
--
Stu












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro with protect sheet Pyrite Excel Discussion (Misc queries) 1 October 10th 08 05:03 PM
Protect macro from stopping saman110 via OfficeKB.com Excel Discussion (Misc queries) 1 August 16th 07 08:22 PM
Protect macro ST Excel Discussion (Misc queries) 1 June 6th 06 06:26 PM
How to protect my macro Protect & Unprotect Several Worksheets Excel Discussion (Misc queries) 1 January 7th 05 02:01 AM
Macro to protect with pword in 97 Wes[_4_] Excel Programming 1 September 15th 03 05:34 PM


All times are GMT +1. The time now is 01:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"