MrExcel Publishing
Your One Stop for Excel Tips & Solutions

97 / 2000 VBA code compatibility question


Posted by Chris on August 07, 2001 7:48 PM

when using the following code:

ActiveSheet.Unprotect password:=""
.
.(data Input to workbook procedure here)
.
Workbooks(ThisBook).Worksheets(1).Activate
ActiveSheet.Protect

...this works fine in excel 2000 but trips up on the last line (AciveSheet.Protect)in excel 97???

can anyone help and tell me if theres a way to accomplish unprotecting/ protecting the workbook for data access purposes that will work across both softwares?

Thanks,
Chris


Posted by Dax on August 08, 2001 1:56 AM

(data Input to workbook procedure here)

Morning,

The line Activesheet.Protect will work fine in XL97 or XL2000. In your code you've used this line :-

Workbooks(ThisBook).Worksheets(1).Activate

Is ThisBook defined as a string and does it have the name of the workbook attached to it? You could replace your code with this:-

ThisWorkbook.Worksheets(1).Protect

HTH,
Dax.


Posted by Chris on August 08, 2001 7:49 AM

(data Input to workbook procedure here)


Dax -

Thanks -
Found the problem - the wbook was not ever getting opened (it seems that cbo.text is not updated the same in excel 97 as it is in 2000 guess???)

-Chris