+ Reply to Thread
Results 1 to 2 of 2

What am I doing wrong? (Unprotecting worksheet from other doc)

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2007
    Posts
    1

    What am I doing wrong? (Unprotecting worksheet from other doc)

    Dim sheet2 As String
    sheet2 = "C:\Documents and Settings\MIS_RBH.MOBILERS\Desktop\Excel Project\Markup.xls"
        
    Workbooks.Open (sheet2)
    
    Dim password As String
    password = "mobilers"
    
    'start
    
    ActiveWorkbook.Sheet1.Unprotect password
    
    ' I also tried - 
    
    '    For Each wSheet In Worksheets
    '        If wSheet.ProtectContents = True Then
    '            wSheet.Unprotect password:=password
    '        Else
    '
    '         ' Do nothing
    '
    '        End If
    '    Next wSheet
    
    
    If wSheet.ProtectContents = True Then
    
    MsgBox "still locked"
    
    Exit Sub
    
    Else
    
    MsgBox "open"
    
    Exit Sub
    End If
    Anybody help me? Please!!!

  2. #2
    Forum Contributor Tarball's Avatar
    Join Date
    04-21-2007
    Location
    Atlanta, GA
    Posts
    166
    Are you attempting to open a workbook from code in a seperate workbook? Then, once open, make sure that the Protection in the workbook that was just opened has been turned off?

    This was not tested. You should make sure you are referencing the sheets in the Workbook that you want to manipulate.

        Dim wb As Workbook
        Dim ws as Worksheet
    
        wb = Excel.Workbooks.Open(fullPath)
        Set ws = wb.Sheets(SheeetName)
        
        If ws.ProtectContents = True Then
            MsgBox "still locked"
        Else
            MsgBox "open"
        End If

+ 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