+ Reply to Thread
Results 1 to 4 of 4

My Code For Protecting Isn't working

  1. #1
    Registered User
    Join Date
    11-25-2020
    Location
    Brazil
    MS-Off Ver
    Office365
    Posts
    1

    My Code For Protecting Isn't working

    I'm trying to make it work:

    But for some reason it's not working. There is a 1004 error at:


    Please Login or Register  to view this content.
    And the button are not working either. Even if i cancel the protection and unprotection functions.

    Don't know what it's happening.

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 11-25-2020 at 08:00 PM. Reason: Please read the rules and use code tags

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: My Code For Protecting Isn't working

    1004 is application defined or object defined error. with the method you are using, it could be any number of things. VBA isn't the greatest languages in the world, and is completely inconsistent in many ways. MS's fault, totally. see these first:

    https://www.google.com/search?q=excel+vba+.Protect+

    https://docs.microsoft.com/en-us/off...ksheet.protect

    https://www.google.com/search?q=vba+excel+1004+error

    https://stackoverflow.com/questions/...or-when-select

    then, maybe try all of the following as possible fixes
    PHP Code: 
    Sheets("Formulario de Nova Contratacao").Protect Password:="3,1415"DrawingObjects:=-1Contents:=-1Scenario:=-
    PHP Code: 
    Sheets("Formulario de Nova Contratacao").Protect Password:="3,1415"TrueTrueTrue 
    PHP Code: 
    Sheets("Formulario de Nova Contratacao").Protect "3,1415"TrueTrueTrue 
    furthermore, are you sure the code is the issue? If there is no sheet called Formulario de Nova Contratacao, that would also cause the error, obviously. no defined object in that case.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: My Code For Protecting Isn't working

    The named argument is Scenarios, plural.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: My Code For Protecting Isn't working

    wow. nice catch andy!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help: Macro NOT Working After Protecting Sheet
    By g1987 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2020, 09:02 AM
  2. [SOLVED] Protecting Sheet stops searching from working
    By VisionSmart in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2018, 12:46 AM
  3. [SOLVED] Protect Sheet not working after protecting workbook?
    By Nonie in forum Excel General
    Replies: 1
    Last Post: 06-24-2014, 10:29 PM
  4. [SOLVED] How to get control back from rogue code that keeps protecting my sheet wwhen I'm working
    By nje in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2013, 09:14 AM
  5. [SOLVED] Protecting all but one worksheet macro not working
    By Shauna in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2012, 01:24 PM
  6. Password protecting a workbook prevents Macros from working.
    By PeterMcCarthy in forum Excel General
    Replies: 3
    Last Post: 02-07-2012, 07:01 PM
  7. up down arrows not working after protecting sheet
    By Computer Man 678 in forum Excel General
    Replies: 2
    Last Post: 12-04-2005, 07:15 PM

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