Results 1 to 9 of 9

Compile error: Method or data member not found error [Only on Mac; OK on Windows]

Threaded View

skysurfer Compile error: Method or data... 10-03-2019, 12:13 PM
6StringJazzer Re: Compile error: Method or... 10-03-2019, 01:55 PM
skysurfer Re: Compile error: Method or... 10-03-2019, 02:07 PM
romperstomper Re: Compile error: Method or... 10-04-2019, 03:46 AM
skysurfer Re: Compile error: Method or... 10-04-2019, 10:29 AM
romperstomper Re: Compile error: Method or... 10-04-2019, 10:32 AM
skysurfer Re: Compile error: Method or... 10-04-2019, 10:53 AM
romperstomper Re: Compile error: Method or... 10-04-2019, 10:59 AM
skysurfer Re: Compile error: Method or... 10-04-2019, 11:19 AM
  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Compile error: Method or data member not found error [Only on Mac; OK on Windows]

    Hi,

    I have the following code that works perfectly on a Windows machine, but generates that compile error on a Mac.

    The piece of code that blows up is ".Unprotect" in this simple loop:

        For Each ws In ThisWorkbook.Worksheets
            ws.Unprotect Password:=pWord
        Next ws
    The entire macro where that code snippet lies is:
    Sub Protection_Off()
    
        Dim pWord As String
        Dim ws As Worksheet
        
        pWord = InputBox("Please enter the password", "Model Protection")
        
        If pWord = "" Or StrPtr(pWord) = 0 Then
        Sheet2.OLEObjects("opt_AdministrationSheets_Hide").Object.Value = True
        Exit Sub
        End If
        
        On Error GoTo ErrorTrap1
        
        Application.ScreenUpdating = False
    
    '   Workbook protection
        ActiveWorkbook.Unprotect Password:=pWord
        
    '   Worksheet protection
        For Each ws In ThisWorkbook.Worksheets
            ws.Unprotect Password:=pWord
        Next ws
        
        For Each ws In ThisWorkbook.Worksheets
            ws.Visible = xlSheetVisible
        Next ws
           
        NamedRanges_Show
        TableOfContents_ShowAdminRows
    
    '   Make the ToC tab the active window
        Application.Goto reference:=Sheet2.Range("A1"), Scroll:=True
        
        MsgBox "Protection disabled.", vbExclamation, "Model Protection"
        
        Application.ScreenUpdating = True
        
        Exit Sub
        
    ErrorTrap1:
        Sheet2.OLEObjects("opt_AdministrationSheets_Hide").Object.Value = True
        Application.ScreenUpdating = True
        MsgBox "Password incorrect - protection still enabled.", vbExclamation, "Model Protection"
        Exit Sub
        
    End Sub
    Thanks for any guidance on this!

    Lawrence
    Last edited by 6StringJazzer; 10-03-2019 at 01:55 PM. Reason: clarified title

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compile Error: Method or data member not found
    By jtsev13 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-24-2018, 04:07 AM
  2. [SOLVED] compile error method or data member not found will not run as a sub
    By COURTTROOPER in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-05-2018, 12:31 PM
  3. Error Message: Compile Error: Method or data Member not found
    By blei in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2017, 08:47 AM
  4. Error Message: Compile Error: Method or data Member not found
    By blei in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2017, 05:20 AM
  5. Compile Error Method or data member not found
    By ixelister in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2014, 03:39 PM
  6. [SOLVED] Compile error: Method or data member not found.
    By ndtsteve in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-10-2012, 11:31 AM
  7. [SOLVED] Compile Error Method or data member not found
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2005, 06:05 PM

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