Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Protect workbook

I'm trying two things that aren't working and it's driving me nuts. I need
my workbook protected when the workbook is opened. For some reason, workbook
protection is a toggle. I'll open it once and it's protected. I'll open it
next time and it's not protected. The other thing I can't get to work is to
turn on autofilter in sheet 'ImportData' each time the workbook opens. Any
ideas what I'm doing wrong? I've tried for hours. . . thanks.

Here's my code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveSheet.AutoFilterMode = False
End Sub

Private Sub Workbook_Open()

On Error Resume Next
AddIns("Analysis ToolPak").Installed = True
AddIns("Analysis ToolPak - VBA").Installed = True

Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect password:="mwimport"
Next ws

Worksheets("ImportData").Range("A1:P5000").Locked = True
Worksheets("Trends").Range("A1:BC25").Locked = True
Worksheets("Chart Data").Range("A1:W72").Locked = True

Dim wsh As Worksheet
For Each wsh In ThisWorkbook.Worksheets
wsh.Protect password:="mwimport"
Next wsh

'Hide the OriginalTrends sheet
Sheets("OriginalTrends").Visible = False

Worksheets("ImportData").Unprotect password:="mwimport"
Worksheets("ImportData").Activate
Range("A1").Select
ActiveSheet.AutoFilterMode = True
ActiveWorkbook.Protect password:="mwimport"

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Protect workbook

I need my workbook protected when the workbook is opened.

It's protected when I open it.

The other thing I can't get to work is to turn on autofilter in sheet 'ImportData' each time the workbook opens.


From excel 2000 vba help

AutoFilterMode Property


True if the AutoFilter drop-down arrows are currently displayed on the
sheet. This property is independent of the FilterMode property. Read/
write Boolean.

Remarks

This property returns True if the drop-down arrows are currently
displayed. You can set this property to False to remove the arrows,
but you cannot set it to True. Use the AutoFilter method to filter a
list and display the drop-down arrows.
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
Can protect worksheet then workbook but not Protect and Share in code [email protected] Excel Programming 7 January 16th 17 07:01 AM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Disable Tools, Protect, Protect Workbook Paul Moles Excel Programming 1 September 5th 05 03:37 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Protect workbook? Marc[_20_] Excel Programming 0 March 28th 05 11:27 PM


All times are GMT +1. The time now is 12:34 AM.

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"