Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default unprotecting sheets in another workbook (syntax problem?)


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

--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default unprotecting sheets in another workbook (syntax problem?)

Sub unprotectsheets()
For i = 2 To 4
With Sheets(i)
..Unprotect
'.Visible = True
'why make visible?
End With
Next i
End Sub

be sure to save

--
Don Guillett
SalesAid Software

"KR" wrote in message
...

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

--
The enclosed questions or comments are entirely mine and don't represent
the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unprotecting Sheets Zee[_2_] New Users to Excel 6 November 26th 08 03:58 PM
Unprotecting Sheets with VBA and IRM Howard Excel Programming 1 August 1st 06 10:03 AM
Unprotecting Sheets Darren Excel Programming 1 May 18th 06 08:22 PM
Unprotecting Sheets with VBA and IRM Philip Excel Programming 0 December 4th 05 04:18 AM
unprotecting sheets one Excel Programming 2 April 17th 04 07:06 PM


All times are GMT +1. The time now is 11:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"