Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
HBj HBj is offline
external usenet poster
 
Posts: 4
Default Protect/Unprotect w/ VBA not working as supposed...

Hello,

My protecting Excel 97 VBA-code is as follows
With ActiveWorkbook.Sheets("MAIN")
.EnableSelection = xlUnlockedCells
.EnableAutoFilter = True
.Protect Contents:=True, userInterfaceOnly:=True

One of the Unprotect codes is
Sheets("Main").Select
ActiveSheet.Unprotect

....but

....after unprotect, copy/paste is not possible. What can be wrong with the
protect code? How can I restore the complete unprotect state?

HBj


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Protect/Unprotect w/ VBA not working as supposed...

Is the Unprotect line in the same macro AND preceeding the Protect line?

If so, is it possible that the code is being bypassed by
Application.EnableEvents = False

What happens if you place a breakpoint on the Protect line and
then run the sub? Does the code break on this line? If not,
your code is skipping over this area.

"HBj" wrote:

Hello,

My protecting Excel 97 VBA-code is as follows
With ActiveWorkbook.Sheets("MAIN")
.EnableSelection = xlUnlockedCells
.EnableAutoFilter = True
.Protect Contents:=True, userInterfaceOnly:=True

One of the Unprotect codes is
Sheets("Main").Select
ActiveSheet.Unprotect

....but

....after unprotect, copy/paste is not possible. What can be wrong with the
protect code? How can I restore the complete unprotect state?

HBj



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Protect/Unprotect w/ VBA not working as supposed...

Sub UnProtect()
Dim i As Integer
Dim SheetCount As Integer
Dim SheetName As String

SheetCount = ActiveWorkbook.Sheets.Count

For i = 1 To SheetCount
SheetName = ActiveWorkbook.Sheets(i).Name
ActiveWorkbook.Sheets(i).UnProtect
Next i
End Sub

Sub Protect()
Dim i As Integer
Dim SheetCount As Integer
Dim SheetName As String

SheetCount = ActiveWorkbook.Sheets.Count

For i = 1 To SheetCount
SheetName = ActiveWorkbook.Sheets(i).Name
ActiveWorkbook.Sheets(i).Protect
ActiveSheet.EnableSelection = xlUnlockedCells
Next i
End Sub

"HBj" wrote:

Hello,

My protecting Excel 97 VBA-code is as follows
With ActiveWorkbook.Sheets("MAIN")
.EnableSelection = xlUnlockedCells
.EnableAutoFilter = True
.Protect Contents:=True, userInterfaceOnly:=True

One of the Unprotect codes is
Sheets("Main").Select
ActiveSheet.Unprotect

....but

....after unprotect, copy/paste is not possible. What can be wrong with the
protect code? How can I restore the complete unprotect state?

HBj



  #4   Report Post  
Posted to microsoft.public.excel.programming
HBj HBj is offline
external usenet poster
 
Posts: 4
Default Protect/Unprotect w/ VBA not working as supposed...

I tested those two subs, saved the file to a new file and tested once mo
Edit/Paste remains grayed. I do not know much about the functioning of the
protection command options used, but I'm afraid that the options I've used
should be cancelled by another function than just the plain .Unprotect. Am I
right?

HBj

"asmenut" wrote in message
...
Sub UnProtect()
Dim i As Integer
Dim SheetCount As Integer
Dim SheetName As String

SheetCount = ActiveWorkbook.Sheets.Count

For i = 1 To SheetCount
SheetName = ActiveWorkbook.Sheets(i).Name
ActiveWorkbook.Sheets(i).UnProtect
Next i
End Sub

Sub Protect()
Dim i As Integer
Dim SheetCount As Integer
Dim SheetName As String

SheetCount = ActiveWorkbook.Sheets.Count

For i = 1 To SheetCount
SheetName = ActiveWorkbook.Sheets(i).Name
ActiveWorkbook.Sheets(i).Protect
ActiveSheet.EnableSelection = xlUnlockedCells
Next i
End Sub

"HBj" wrote:

Hello,

My protecting Excel 97 VBA-code is as follows
With ActiveWorkbook.Sheets("MAIN")
.EnableSelection = xlUnlockedCells
.EnableAutoFilter = True
.Protect Contents:=True, userInterfaceOnly:=True

One of the Unprotect codes is
Sheets("Main").Select
ActiveSheet.Unprotect

....but

....after unprotect, copy/paste is not possible. What can be wrong with

the
protect code? How can I restore the complete unprotect state?

HBj





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
Protect, unprotect Pyrite Excel Discussion (Misc queries) 0 August 15th 08 03:18 PM
Is there any way that you can protect or unprotect a group of wor. CheriT63 Excel Discussion (Misc queries) 9 January 8th 05 08:40 PM
Unprotect and protect.... Wilfrid Excel Programming 1 July 28th 04 03:13 AM
protect / unprotect worksheets using VBA ExcelUserinPA Excel Programming 2 November 1st 03 03:36 PM
Protect\Unprotect VBA project Rohit Thomas Excel Programming 2 August 28th 03 04:16 PM


All times are GMT +1. The time now is 10:53 AM.

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

About Us

"It's about Microsoft Excel"