View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Password Protecting/Unprotecting Worksheets using VBA code?

Of course not. There is nothing unexpected or adverse in what you do, and we
are free to ignore you <bg.

Keep asking, we'll keep answering.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"dim" wrote in message
...
Thanks 'again' Bob,

I hope Im not annoying everyone with all my question, but VBA code is new
to
me, and anything I learn I add into my library so I don't have to ask
again.

Thanks.

"Bob Phillips" wrote:

With Worksheets("Sheet1")
.Unprotect "password"
.Rows(2).Insert
.Protect "password"
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"dim" wrote in message
...
Hi folks,

I have a workbook called Book2. A macro opens Book2, inserts and saves
user
data, then closes Book2.

This all worked fine until I just tried it out with the password
applied
to
Book2. the password is "pswd". When the code attempts to insert a row
into
Book2's sheet as below, it hangs because it cant insert a row when all
the
cells are locked. I thought this might happen, thats why I tested it
now.
But
I dont know the VBA code I need....

Rows("2:2").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

Can someone please tell me what to add to the code to unprotect the
sheet
using the password, then reprotect it before saving and closing?

Thankyou.