+ Reply to Thread
Results 1 to 2 of 2

unprotecting sheets in another workbook (syntax problem?)

  1. #1
    KR
    Guest

    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. #2
    Don Guillett
    Guest

    Re: 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
    [email protected]
    "KR" <[email protected]> wrote in message
    news:[email protected]...
    >
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1