i'm a windows users and have no Mac osx experience, so please help me , thank you verymuch
( The below code works well on windows but cannot run on Mac osx )
Private Sub Workbook_Open() ' check internet connection Dim oPing As Object, oRetStatus As Object, i As Byte Dim vt As Workbook Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _ ("select * from Win32_PingStatus where address = '8.8.8.8'") For Each oRetStatus In oPing If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then i = 0 Else i = 1 End If Next If i = 0 Then MsgBox "No internet connection" Else Set vt = ThisWorkbook ' open file on ftp server and do something On Error Resume Next Workbooks.Open Filename:="path on ftp server", password:="111" If Error.Number = 0 Then If Workbooks("abc.xlsx").Sheets(1).Cells(1, "Z").Value > vt.Sheets(1).Cells(1, "Z").Value Then If MsgBox("message", vbOKCancel, "name") = vbOK Then vt.Sheets(1).Cells(1, "Z").Value = Workbooks("abc.xlsx").Sheets(1).Cells(1, "Z").Value vt.Worksheets(1).Unprotect ("111") Workbooks("abc.xlsx").Sheets(1).Rows("1:200").Copy vt.Sheets(1).Rows.Range("1:200").PasteSpecial Paste:=xlPasteAll vt.Worksheets(1).Protect ("111") Application.CutCopyMode = False Workbooks("abc.xlsx").Close vt.Sheets(1).Cells(1, 1).Select vt.Save Else Workbooks("abc.xlsx").Close End If End If Else Err.Clear End If Workbooks("abc.xlsx").Close End If End Sub






Reply With Quote