K
KR
I am cycling through 250+ Excel 2003 workbooks on a network drive (using
Excel 2003).
My most recent challenge is to remove any protection on 3 of the sheets in
each workbook (Sheet4, Sheet5, Sheet6).
I dim'ed a variable [TempBook] and use it in my loop to work with each
workbook, but when I get to the code to unprotect the three sheets, I can't
get it to work. I'm assuming it is either a syntax issue, or a requirement
related to the sheet's current properties (active, hidden, etc.). All three
sheets are normally hidden.
Set TempBook = Workbooks.Open(MyPath & MyFiles(Fnum), 0, False) 'opens the
file just fine
I tried variations on the following, but so far the VBE doesn't like any of
these. If the first line didn't work I'd skip to the next in case it wasn't
necessary, but it doesn't seem to like any of them:
TempBook.Sheet4.unhide '(no password)
TempBook.Sheet4.activate
TempBook.Sheet4.unprotect
and
TempBook.Sheets("PS").unhide '(no password)
TempBook.Sheets("PS").activate
TempBook.Sheets("PS").unprotect
Then the real joy is when I try to exit, something about my code is kind
enough to kill Excel's instance with an unrecoverable error <sigh>
Any help on the syntax (or other things to look out for) would be greatly
appreciated.
Thanks,
Keith
Excel 2003).
My most recent challenge is to remove any protection on 3 of the sheets in
each workbook (Sheet4, Sheet5, Sheet6).
I dim'ed a variable [TempBook] and use it in my loop to work with each
workbook, but when I get to the code to unprotect the three sheets, I can't
get it to work. I'm assuming it is either a syntax issue, or a requirement
related to the sheet's current properties (active, hidden, etc.). All three
sheets are normally hidden.
Set TempBook = Workbooks.Open(MyPath & MyFiles(Fnum), 0, False) 'opens the
file just fine
I tried variations on the following, but so far the VBE doesn't like any of
these. If the first line didn't work I'd skip to the next in case it wasn't
necessary, but it doesn't seem to like any of them:
TempBook.Sheet4.unhide '(no password)
TempBook.Sheet4.activate
TempBook.Sheet4.unprotect
and
TempBook.Sheets("PS").unhide '(no password)
TempBook.Sheets("PS").activate
TempBook.Sheets("PS").unprotect
Then the real joy is when I try to exit, something about my code is kind
enough to kill Excel's instance with an unrecoverable error <sigh>
Any help on the syntax (or other things to look out for) would be greatly
appreciated.
Thanks,
Keith