+ Reply to Thread
Results 1 to 3 of 3

Error: Cannot Set Range Class Property

  1. #1
    Registered User
    Join Date
    08-01-2006
    Posts
    1

    Question Error: Cannot Set Range Class Property

    I've been trying to Get Excel to Change Worksheet Protection Password using the Locked Property without success.

    This is the situation:

    1. I had the properties (format) of specific ranges set to 'Unlocked'
    2. I then protected the Worksheet containing those ranges with a password
    3. I now tried to unlock the Worksheet and set those specific cells to 'locked' programmatically
    e.g
    Please Login or Register  to view this content.
    where range("X11:Y34") represents the specific unlocked cells

    Result:
    I get and Error Message:
    Run-time Error 1004. Could not set Range Class property.

    What did I do wrong?

  2. #2

    Re: Error: Cannot Set Range Class Property

    Hi
    you shouldn't have parenthesis on the unprotect:

    Worksheets(1).Unprotect Password:="My Password"

    The locked stuff looks OK.
    regards
    Paul

    2hOt wrote:
    > I've been trying to Get Excel to Change Worksheet Protection Password
    > using the -Locked Property -without success.
    >
    > THIS IS THE SITUATION:
    >
    > *1.* I had the properties (format) of specific ranges set to
    > 'Unlocked'
    > *2.* I then protected the Worksheet containing those ranges with a
    > password
    > *3.* I now tried to unlock the Worksheet and set those specific cells
    > to 'locked' *programmatically*
    > e.g
    >
    > Code:
    > --------------------
    > worksheet(1).Unprotect('the password')
    > worksheets(1).range("X11:Y34").locked = False
    > --------------------
    >
    > where range("X11:Y34") represents the specific unlocked cells
    >
    > RESULT:
    > I get and Error Message:
    > Run-time Error 1004. Could not set Range Class property.
    >
    > What did I do wrong?
    >
    >
    > --
    > 2hOt
    > ------------------------------------------------------------------------
    > 2hOt's Profile: http://www.excelforum.com/member.php...o&userid=36977
    > View this thread: http://www.excelforum.com/showthread...hreadid=566981



  3. #3
    ImpulseBlue
    Guest

    Re: Error: Cannot Set Range Class Property

    The parentheses do not matter, its just a shortcut way since the only
    argument Unprotect requires is the password. I copied and ran your
    code exactly, with the exception of worksheet(1) should be
    worksheets(1)... it ran fine for me. I think your problem might be
    somewhere else.


    [email protected] wrote:
    > Hi
    > you shouldn't have parenthesis on the unprotect:
    >
    > Worksheets(1).Unprotect Password:="My Password"
    >
    > The locked stuff looks OK.
    > regards
    > Paul
    >
    > 2hOt wrote:
    > > I've been trying to Get Excel to Change Worksheet Protection Password
    > > using the -Locked Property -without success.
    > >
    > > THIS IS THE SITUATION:
    > >
    > > *1.* I had the properties (format) of specific ranges set to
    > > 'Unlocked'
    > > *2.* I then protected the Worksheet containing those ranges with a
    > > password
    > > *3.* I now tried to unlock the Worksheet and set those specific cells
    > > to 'locked' *programmatically*
    > > e.g
    > >
    > > Code:
    > > --------------------
    > > worksheet(1).Unprotect('the password')
    > > worksheets(1).range("X11:Y34").locked = False
    > > --------------------
    > >
    > > where range("X11:Y34") represents the specific unlocked cells
    > >
    > > RESULT:
    > > I get and Error Message:
    > > Run-time Error 1004. Could not set Range Class property.
    > >
    > > What did I do wrong?
    > >
    > >
    > > --
    > > 2hOt
    > > ------------------------------------------------------------------------
    > > 2hOt's Profile: http://www.excelforum.com/member.php...o&userid=36977
    > > View this thread: http://www.excelforum.com/showthread...hreadid=566981



+ Reply to Thread

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