Results 1 to 3 of 3

why so many problems with this code in 97 and not in 2000

This is a discussion on why so many problems with this code in 97 and not in 2000 within the Excel Questions forums, part of the Question Forums category; First thanks to all who've helped on this project. The code I'm referring to is: activeSheet.Unprotect ("password") Activesheet.Protect ("password") And ...

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    383

    Default

    First thanks to all who've helped on this project.

    The code I'm referring to is:

    activeSheet.Unprotect ("password")
    Activesheet.Protect ("password")

    And

    sheet1.Unprotect ("password")
    Sheet1.protect ("password")

    and
    with activesheet
    .unprotect ("password")
    .additional code
    .additional code
    end with

    I cannot get either of the above to work in 97. All works great in 2000 but the user of the workbook will be using 97 so I need to find a way to unprotect the sheets when I need to without unprotecting the entire workbook just so he can use it.

    I'm at a loss.

    I appreciate the help from everyone at Mr. Excel.

    viper

  2. #2
    Board Regular
    Join Date
    May 2002
    Posts
    810

    Default

    You need to give us a chronology of the errors, as you run the code in debug mode.

    If the code is not protected, you will be given the Debug option upon errors.

    After the first error message, click on Debug.

    Now, where are you? You need to copy and paste the offending passage of code into your next post to this thread, letting us know what the first error message said, where you were tossed back into the code.

    From that point, we can offer suggestions as to remedy, and you can try again, and perhaps get back to us where the second error (if any) occurs.

    As to obvious problems, I was looking for Activate/Select methods, or perhaps trying to read a value of merged cells. 97 and XP have some differences on these two issues.


  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    383

    Default

    Any of the listed ways I've tried to unprotect the sheet before coping, deleting any content from the worksheet(s). I get the same error at the same point. Right now I get a run time error 1004, unprotect of the object worksheet failed.

    Right now the code I'm using is:

    Sheet1.Unprotect ("password")'error code
    With ActiveSheet

    .Range("E3").ClearContents
    .Range("D5").ClearContents
    .Range("c9:d250").ClearContents
    On Error Resume Next
    .Range("A9:A250").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0

    End With
    Sheet1.Protect ("password")'error code


    Sheet2.Unprotect ("password")'error code
    With Sheets("Invoice listing")
    .Range("a2:b200").ClearContents

    End With
    Sheet2.Protect ("password")'error code

    Where I've pointed out the error code lines I get each time in 97. If I unprotect the sheet prior to runnin the macro the unprotect is okay but then the error occurs in the protect part.


    I appreciate the help from everyone at Mr. Excel.

    viper

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com