Compile Error: Method or data member not found

DWhit217

New Member
Joined
Mar 29, 2012
Messages
21
I'm getting the "Compile Error: Method or data member not found" error on the following line of code on my co-workers computer but I have no issues on my computer. We are running the same version of Excel (2016 on a MAC), any idea what the issue could be?

Error on

Rich (BB code):
mybook.Close savechanges:=False

With the ".Close" highlighted.

Pretty much everything I check between the two machines is exactly the same. Any guidance is greatly appreciated. Also I apologize in advance of the sloppiness of the code, I'm a total newb.

The full code is below

Code:
Sub Update_Price()
    Dim MyPath As String, FilesInPath As String
    Dim MyFiles() As String, Fnum As Long
    Dim FileName As String
    Dim mybook As Workbook
    Dim CalcMode As Long
    Dim sh As Worksheet
    Dim ErrorYes As Boolean


    'Fill in the path\folder where the files are
    MyPath = MacScript("return POSIX path of (path to desktop folder) as string")
    MyPath = Replace(MyPath, "/Desktop", "") & _
        "Library/Group Containers/UBF8T346G9.Office/Master Key/Update/"


    'If there are no Excel files in the folder exit the sub
    FilesInPath = Dir(MyPath)
    If FilesInPath = "" Then
        MsgBox "No files found"
        Exit Sub
    End If


    'Fill the array(myFiles)with the list of Excel files in the folder
    Fnum = 0
    Do While FilesInPath <> ""
        Fnum = Fnum + 1
        ReDim Preserve MyFiles(1 To Fnum)
        MyFiles(Fnum) = FilesInPath
        FilesInPath = Dir()
    Loop


    With Application
        CalcMode = .Calculation
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
        .EnableEvents = False
    End With


    'Loop through all files in the array(myFiles)
    If Fnum > 0 Then
        For Fnum = LBound(MyFiles) To UBound(MyFiles)
            Set mybook = Nothing
            On Error Resume Next
            Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum))


            If Not mybook Is Nothing Then




                'Change cell value(s) in one worksheet in mybook
                With mybook.Worksheets("Project")
                        .Range("G25") = Format(Now(), "mm-dd-yy")
                        .Range("H25") = Format(Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C27").Value, "mm-dd-yy")
                        .Range("I25") = Format(Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("D27").Value, "mm-dd-yy")
                        '.Range("G19") = DateAdd("m", 3, Now())
                        '.Range("E17:E27").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C4:C14").Value
                        
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C4").Value = 0 Then
                        .Range("E17").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C4").Value
                End If
                 
                 If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C5").Value = 0 Then
                        .Range("E18").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C5").Value
                End If
                        
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C6").Value = 0 Then
                        .Range("E19").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C6").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C7").Value = 0 Then
                        .Range("E20").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C7").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C8").Value = 0 Then
                        .Range("E21").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C8").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C9").Value = 0 Then
                        .Range("E22").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C9").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C10").Value = 0 Then
                        .Range("E23").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C10").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C11").Value = 0 Then
                        .Range("E24").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C11").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C12").Value = 0 Then
                        .Range("E25").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C12").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C13").Value = 0 Then
                        .Range("E26").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C13").Value
                End If
                
                If Not Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C14").Value = 0 Then
                        .Range("E27").Value = Workbooks("Master_Key.xlsm").Worksheets("Master_Key").Range("C14").Value
                End If
                
                        Application.Calculate
                        FileName = Range("C11")
                        ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite
                        Application.ActiveWorkbook.SaveAs MyPath & FileName, FileFormat:=52
                        mybook[B].Close[/B] savechanges:=False
                    End With
            End If


        Next Fnum
    End If


    With Application
        .ScreenUpdating = True
        .EnableEvents = True
        .Calculation = CalcMode
    End With


End Sub
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Check that there are no subs called Close, on your co workers m/c.
Also check to see if there any variables called Close
 
Upvote 0
Are you using the same workbook on both computers?
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top