Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home

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


Check out our Excel VBA Resources

Re: 97 / 2000 VBA code compatibility question

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.



Re: 97 / 2000 VBA code compatibility question

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



This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.