LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Protect sheet with PivotTable based on OLAP data

Hi,

Like the subject says :o)
I want to protect a sheet on which I have a PivotTable that is based
on OLAP Data.
Also I want to give the enduser the possibility to change the
pagefields. (that's the tricky part)

I added this code:

Private Sub Workbook_Open()

With Sheet1
.Unprotect 'No password for now
.PivotTables(1).PivotCache.Refresh
.Protect Contents:=True, UserInterfaceOnly:=True,
AllowUsingPivotTables:=True
.EnableOutlining = True 'Otherwise Grouping will not work
End With

End sub

But when I change the pagefields the pivottable must connect again to
the source and does give me a nice messagebox:

"That command cannot be performed on a protected sheet because the
source data for this PivotTable report requires a data refresh. To
remove protection... please...again"

The annoying thing is that I can't catch an PivotTable event after the
PivotTable selection change to unprotect and protect again, and
meanwhile do a PivotCache.Refresh.
The Worksheet_PivotTableUpdate occurs after update ;o(

I have an alternative solution (with thx to Dave Peterson:
http://groups.google.be/group/micros...e3b986806709b7)
But i don't like the undo statement ;o), i would have preferred a
Cancel flag ...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Set myRng = Me.Range("AGRegionsProtected")
On Error GoTo errHandler:
If Intersect(Target, myRng) Is Nothing Then
'let 'em do it
Else
With Application
.EnableEvents = False
.Undo
End With
MsgBox "I've asked you not to change this range!"
End If
errHandler:
Application.EnableEvents = True
End Sub

An other approach is to buid your own custom MDX browse comboboxes for
replacing the Pagefields...

Thanks for reading and suggestions!

 
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
How do I protect a sheet with a pivotTable in it? Candj Excel Discussion (Misc queries) 0 February 15th 08 06:22 PM
#VALUE! in OLAP based PivotTable Pasha[_2_] Excel Programming 0 December 6th 05 10:16 PM
pivottable and OLAP cubes willcob Excel Worksheet Functions 0 May 25th 05 11:57 AM
Excel pivottable with OLAP cubes saves names, not keys jerome Excel Discussion (Misc queries) 0 April 13th 05 07:49 AM
How to sort a PivotTable based on OLAP Cube by one of the data fi. JM Excel Programming 0 February 16th 05 01:15 PM


All times are GMT +1. The time now is 05:50 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"