Results 1 to 3 of 3

Problem with excel security settings causing UserInterFaceOnly to not work

Threaded View

  1. #1
    Registered User
    Join Date
    11-09-2010
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    32

    Problem with excel security settings causing UserInterFaceOnly to not work

    Hi,

    I have a workbook that has the following code in the "This Workbook" page

    [Private Sub Workbook_Open()
    Dim wSht As Worksheet
    
     'set protection using UserInterface to allow macros to work
      For Each wSht In ActiveWorkbook.Sheets
            wSht.Protect _
                DrawingObjects:=True, _
                Contents:=True, _
                Scenarios:=True, _
                UserInterfaceOnly:=True
        Next wSht
        Sheets("Home").Activate
    End Sub
    This code protects every sheet but allows macros to run. It seems to work fine when I open the workbook from my documents as this is a trusted source in my excel settings.

    The problem is that when I send it to other users, the excel security warning that disables 'Active content' etc seems to stop this from working properly. Even if the user clicks 'enable this content', they get 'run-time error 1004 - unable to set the Hidden property of the Range class'

    As I understand it, the UserInterfaceOnly: = True code allows macros to run on protected sheets. It appears that the excel security settings that initially prevent the macros from running has also prevented my workbook open event from running.

    Any idea how to stop this? The workbook has a lot of macros so adding in an 'Unprotect - protect' to each one would be very impractical.

    Thanks in advance for any help.

    Gareth
    Last edited by shg; 01-24-2011 at 01:23 AM. Reason: fix code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1