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

viper

Active Member
Joined
Feb 15, 2002
Messages
382
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.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top